From 85e19d387907a2a0d6438a18abf708aee47d209f Mon Sep 17 00:00:00 2001 From: cai_miao Date: Sat, 21 Nov 2020 00:50:56 +0900 Subject: [PATCH] add leading to config --- Common/Font.cpp | 3 +-- Common/Font.hpp | 8 +++----- D2MFC/Main.cpp | 4 ++++ D2MFC/config.json | 16 +++++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Common/Font.cpp b/Common/Font.cpp index 7a6c14c..d82f513 100644 --- a/Common/Font.cpp +++ b/Common/Font.cpp @@ -177,9 +177,8 @@ void Font::RenderGlyphs() { MaxH = max(MaxH, G->Bmp.Height()); } if (!LnSpacing) - LnSpacingOff = 0; LnSpacing = ceil((float)(MaxH - MaxDescent * 10 / HeightConstant)) + LnSpacingOff; - ActualSpacing = HeightConstant * LnSpacing / 10; + auto ActualSpacing = HeightConstant * LnSpacing / 10; if (ActualSpacing < MaxH) Warn("The maximum height (%zu) of newly generated glyphs is larger than Actual Spacing (%u)", MaxH, ActualSpacing); if (!CapHeight) diff --git a/Common/Font.hpp b/Common/Font.hpp index 4d417c8..c8e3534 100644 --- a/Common/Font.hpp +++ b/Common/Font.hpp @@ -32,12 +32,10 @@ struct Font { vector Pals{}; vector Faces{}; uint32_t Size{}; // The first entry - int32_t LnSpacingOff{}; - int32_t CapHeightOff{}; + int32_t LnSpacingOff{0}; + int32_t CapHeightOff{0}; int32_t DescentPadding{-1}; // -1 for automatic - int32_t HeightConstant{17}; - int32_t DesiredSpacing{}; // dummy - int32_t ActualSpacing{}; // dummy + int32_t HeightConstant{14}; // 14 ENG 15 JPN 17 CHI // Tbl Specific - also by config uint32_t LnSpacing{}; uint32_t CapHeight{}; diff --git a/D2MFC/Main.cpp b/D2MFC/Main.cpp index e1313e9..52e8b63 100644 --- a/D2MFC/Main.cpp +++ b/D2MFC/Main.cpp @@ -61,6 +61,8 @@ int main(int NArg, char* Args[]) { auto FacePath = d["path"].GetString(); uint16_t Size = d["size"].GetInt(); + auto HeightConstant = d["leadingfactor"].GetInt(); + auto LnSpacingOff = d["leadingoffset"].GetInt(); auto PalPath = d["pal"].GetString(); auto Dc6Path = d["dc6name"].GetString(); auto TblPath = d["tblname"].GetString(); @@ -90,6 +92,8 @@ int main(int NArg, char* Args[]) { printf("Preparing glyphs...\n"); Fnt.Size = Size; + Fnt.HeightConstant = HeightConstant; + Fnt.LnSpacingOff = LnSpacingOff; Fnt.Faces.emplace_back(FacePath); for (auto it = glyphlist.cbegin(); it != glyphlist.cend(); it++) { uint16_t Ch = *it; diff --git a/D2MFC/config.json b/D2MFC/config.json index 52e7606..5564af5 100644 --- a/D2MFC/config.json +++ b/D2MFC/config.json @@ -2,16 +2,22 @@ "filename": "font16", "dc6name": "font16.dc6", "tblname": "font16.tbl", + + "leadingfactor": 17, + "leadingoffset": 0, + "pal": "act1-fechar.dat", + "ranges": [ {"range": [0,255], "note":"Latin"}, {"range": [1024,1327], "note":"Cyr"}, - {"range": [12288,12591], "note":"CJ part1"}, - {"range": [19968,40959], "note":"CJ part2"}, - {"range": [65280,65519], "note":"FF00—FFEF Halfwidth and Fullwidth Forms"} + {"range": [12288,12591], "note":"CJ part"}, + {"range": [19968,40959], "note":"CJK Ideograph"}, + {"range": [65280,65519], "note":"FF00-FFEF Halfwidth and Fullwidth Forms"} ], - "bgColorz": [0,0,0], "path": "C:\\Windows\\Fonts\\simsun.ttc", + "path_": ".\\Cascadia.ttf", "size": 14, + "bgColorz": [0,0,0], "aa": false, - "pal": "act1-fechar.dat" + "EOF": "" } \ No newline at end of file