Skip to content

Commit

Permalink
add leading to config
Browse files Browse the repository at this point in the history
  • Loading branch information
CaiMiao committed Nov 20, 2020
1 parent 99d0944 commit 85e19d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Common/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions Common/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ struct Font {
vector<Palette> Pals{};
vector<string> 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{};
Expand Down
4 changes: 4 additions & 0 deletions D2MFC/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions D2MFC/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":"FF00FFEF 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": ""
}

0 comments on commit 85e19d3

Please sign in to comment.