add option 'space width' to RBF export

This commit is contained in:
riva 2024-06-07 16:48:30 +03:00
parent 573cf8cae0
commit 179b5aaac7
8 changed files with 79 additions and 14 deletions

View File

@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2024-05-30 15:39+0300\n"
"PO-Revision-Date: 2024-06-04 00:29+0300\n"
"Last-Translator: user <>\n"
"Language-Team: riva\n"
"Language: en\n"
@ -1798,6 +1798,14 @@ msgstr "Internal name"
msgid "Параметры"
msgstr "Options"
#: tfmrbf.lbspacew.caption
msgid "Ширина пробела, %"
msgstr "Space char width, %"
#: tfmrbf.lbspacew.hint
msgid "Ширина пробела в % от ширины шрифта"
msgstr "Space char width in % of font width"
#: tfmrbf.lbspacing.caption
msgid "Межсимвольное расстояние, пикс."
msgstr "Сharacter spacing, px."

View File

@ -1749,6 +1749,14 @@ msgstr ""
msgid "Параметры"
msgstr ""
#: tfmrbf.lbspacew.caption
msgid "Ширина пробела, %"
msgstr ""
#: tfmrbf.lbspacew.hint
msgid "Ширина пробела в % от ширины шрифта"
msgstr ""
#: tfmrbf.lbspacing.caption
msgid "Межсимвольное расстояние, пикс."
msgstr ""

View File

@ -140,8 +140,8 @@
<AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="2"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="1"/>
<BuildNr Value="83"/>
<RevisionNr Value="2"/>
<BuildNr Value="84"/>
<Language Value="0419"/>
<StringTable Comments="Raster fonts creating and editing. C code generating. Char map and example text preview. Export to image and import from image or code. Must-have tool for embed developers" CompanyName="Riva Lab :: riva-lab.gitlab.io" FileDescription="matrixFont - raster fonts editor" InternalName="matrixFont" LegalCopyright="Riva, 2015-2024" OriginalFilename="matrixFont" ProductName="matrixFont"/>
</VersionInfo>

View File

@ -88,7 +88,7 @@ object fmRbf: TfmRbf
end
object pOptions: TPanel
Left = 0
Height = 116
Height = 148
Top = 96
Width = 667
AutoSize = True
@ -99,7 +99,7 @@ object fmRbf: TfmRbf
ChildSizing.EnlargeVertical = crsHomogenousSpaceResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 116
ClientHeight = 148
ClientWidth = 667
TabOrder = 1
object seSpacing: TSpinEdit
@ -165,23 +165,47 @@ object fmRbf: TfmRbf
Caption = 'Смещение базовой линии снизу, пикс.'
Layout = tlCenter
end
object seSpaceW: TSpinEdit
AnchorSideTop.Side = asrBottom
Left = 0
Height = 28
Top = 96
Width = 150
Constraints.MinWidth = 80
Increment = 5
MaxValue = 100
MinValue = 5
TabOrder = 3
Value = 40
end
object lbSpaceW: TLabel
AnchorSideTop.Side = asrCenter
Left = 160
Height = 28
Hint = 'Ширина пробела в % от ширины шрифта'
Top = 96
Width = 507
Caption = 'Ширина пробела, %'
Layout = tlCenter
end
object pMonospace: TPanel
Left = 0
Height = 20
Top = 96
Top = 128
Width = 150
BevelOuter = bvNone
ChildSizing.EnlargeHorizontal = crsHomogenousSpaceResize
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ClientHeight = 20
ClientWidth = 150
TabOrder = 3
TabOrder = 4
object cbMonospace: TCheckBox
Left = 65
Height = 20
Top = 0
Width = 21
TabOrder = 0
OnChange = OptionChange
end
end
object lbMonospace: TLabel
@ -189,7 +213,7 @@ object fmRbf: TfmRbf
Left = 160
Height = 20
Hint = 'Если флажок не установлен - пропорциональный'
Top = 96
Top = 128
Width = 507
Caption = 'Моноширинный шрифт'
Layout = tlCenter

View File

@ -8,6 +8,8 @@
{"hash":48973022,"name":"tfmrbf.lbinterline.caption","sourcebytes":[208,156,208,181,208,182,209,129,209,130,209,128,208,190,209,135,208,189,208,190,208,181,32,209,128,208,176,209,129,209,129,209,130,208,190,209,143,208,189,208,184,208,181,44,32,208,191,208,184,208,186,209,129,46],"value":"\u041C\u0435\u0436\u0441\u0442\u0440\u043E\u0447\u043D\u043E\u0435 \u0440\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435, \u043F\u0438\u043A\u0441."},
{"hash":106228928,"name":"tfmrbf.lbbaseline.hint","sourcebytes":[208,160,208,176,209,129,209,129,209,130,208,190,209,143,208,189,208,184,208,181,32,208,190,209,130,32,208,189,208,184,208,183,208,176,32,209,133,208,190,208,187,209,129,209,130,208,176,32,208,180,208,190,32,208,177,208,176,208,183,208,190,208,178,208,190,208,185,32,208,187,208,184,208,189,208,184,208,184,32,209,136,209,128,208,184,209,132,209,130,208,176],"value":"\u0420\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435 \u043E\u0442 \u043D\u0438\u0437\u0430 \u0445\u043E\u043B\u0441\u0442\u0430 \u0434\u043E \u0431\u0430\u0437\u043E\u0432\u043E\u0439 \u043B\u0438\u043D\u0438\u0438 \u0448\u0440\u0438\u0444\u0442\u0430"},
{"hash":37571150,"name":"tfmrbf.lbbaseline.caption","sourcebytes":[208,161,208,188,208,181,209,137,208,181,208,189,208,184,208,181,32,208,177,208,176,208,183,208,190,208,178,208,190,208,185,32,208,187,208,184,208,189,208,184,208,184,32,209,129,208,189,208,184,208,183,209,131,44,32,208,191,208,184,208,186,209,129,46],"value":"\u0421\u043C\u0435\u0449\u0435\u043D\u0438\u0435 \u0431\u0430\u0437\u043E\u0432\u043E\u0439 \u043B\u0438\u043D\u0438\u0438 \u0441\u043D\u0438\u0437\u0443, \u043F\u0438\u043A\u0441."},
{"hash":261688144,"name":"tfmrbf.lbspacew.hint","sourcebytes":[208,168,208,184,209,128,208,184,208,189,208,176,32,208,191,209,128,208,190,208,177,208,181,208,187,208,176,32,208,178,32,37,32,208,190,209,130,32,209,136,208,184,209,128,208,184,208,189,209,139,32,209,136,209,128,208,184,209,132,209,130,208,176],"value":"\u0428\u0438\u0440\u0438\u043D\u0430 \u043F\u0440\u043E\u0431\u0435\u043B\u0430 \u0432 % \u043E\u0442 \u0448\u0438\u0440\u0438\u043D\u044B \u0448\u0440\u0438\u0444\u0442\u0430"},
{"hash":50102517,"name":"tfmrbf.lbspacew.caption","sourcebytes":[208,168,208,184,209,128,208,184,208,189,208,176,32,208,191,209,128,208,190,208,177,208,181,208,187,208,176,44,32,37],"value":"\u0428\u0438\u0440\u0438\u043D\u0430 \u043F\u0440\u043E\u0431\u0435\u043B\u0430, %"},
{"hash":170931801,"name":"tfmrbf.lbmonospace.hint","sourcebytes":[208,149,209,129,208,187,208,184,32,209,132,208,187,208,176,208,182,208,190,208,186,32,208,189,208,181,32,209,131,209,129,209,130,208,176,208,189,208,190,208,178,208,187,208,181,208,189,32,45,32,208,191,209,128,208,190,208,191,208,190,209,128,209,134,208,184,208,190,208,189,208,176,208,187,209,140,208,189,209,139,208,185],"value":"\u0415\u0441\u043B\u0438 \u0444\u043B\u0430\u0436\u043E\u043A \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D - \u043F\u0440\u043E\u043F\u043E\u0440\u0446\u0438\u043E\u043D\u0430\u043B\u044C\u043D\u044B\u0439"},
{"hash":43605042,"name":"tfmrbf.lbmonospace.caption","sourcebytes":[208,156,208,190,208,189,208,190,209,136,208,184,209,128,208,184,208,189,208,189,209,139,208,185,32,209,136,209,128,208,184,209,132,209,130],"value":"\u041C\u043E\u043D\u043E\u0448\u0438\u0440\u0438\u043D\u043D\u044B\u0439 \u0448\u0440\u0438\u0444\u0442"},
{"hash":105722585,"name":"tfmrbf.lbfontwiki.hint","sourcebytes":[104,116,116,112,115,58,47,47,101,110,46,119,105,107,105,112,101,100,105,97,46,111,114,103,47,119,105,107,105,47,84,121,112,101,102,97,99,101,95,97,110,97,116,111,109,121],"value":"https://en.wikipedia.org/wiki/Typeface_anatomy"},

View File

@ -22,6 +22,7 @@ type
lbName: TLabel;
lbOptions: TLabel;
lbSpacing: TLabel;
lbSpaceW: TLabel;
pControls: TPanel;
pMain: TPanel;
pMonospace: TPanel;
@ -30,11 +31,13 @@ type
seBaseline: TSpinEdit;
seInterline: TSpinEdit;
seSpacing: TSpinEdit;
seSpaceW: TSpinEdit;
lbFontWiki: TLabel;
procedure FormShow(Sender: TObject);
procedure bbOKClick(Sender: TObject);
procedure lbFontWikiClick(Sender: TObject);
procedure OptionChange(Sender: TObject);
end;
var
@ -82,4 +85,9 @@ procedure TfmRbf.lbFontWikiClick(Sender: TObject);
OpenURL(lbFontWiki.Hint);
end;
procedure TfmRbf.OptionChange(Sender: TObject);
begin
seSpaceW.Enabled := not cbMonospace.Checked;
end;
end.

View File

@ -65,6 +65,7 @@ type
Interline: Integer; // spacing between lines
Baseline: Integer; // baseline offset from bottom of char canvas
Monospace: Boolean; // if TRUE then width will be the same for all chars
SpaceWdth: Integer; // space char #32 width in % of font width
Name: String[FNT_MAX_NAME];
constructor Create;
@ -88,6 +89,7 @@ constructor TRBFFontConverter.Create;
Interline := 2;
Baseline := 2;
Monospace := False;
SpaceWdth := 40;
end;
destructor TRBFFontConverter.Destroy;
@ -127,7 +129,6 @@ procedure TRBFFontConverter.LoadFromFile(AFilename: String);
FFont.Width := MaxWidth;
FFont.FontStartItem := CharFirst;
FFont.FontLength := CharLast - FFont.FontStartItem + 1;
Self.Spacing := Spacing;
Self.Baseline := Baseline;
Self.Interline := Interline;
end;
@ -182,7 +183,7 @@ procedure TRBFFontConverter.SaveToFile(AFilename: String);
begin
with header do
begin
MaxWidth := FFont.Width;
MaxWidth := FFont.Width + Spacing;
CharSize := (MaxWidth + 7) div 8 * FFont.Height;
Points := FFont.Height;
Height := FFont.Height;
@ -205,11 +206,19 @@ procedure TRBFFontConverter.SaveToFile(AFilename: String);
procedure WriteCharWidth;
var
i: Integer;
i, w: Integer;
begin
for i := 0 to FFont.FontLength - 1 do
memstr.WriteByte(Spacing +
Monospace.Select(FFont.Width, FFont.Item[i].GetCharWidth));
begin
if Monospace then
w := FFont.Width + Spacing else
w := FFont.Item[i].GetCharWidth + Spacing;
if not Monospace and (FFont.FontStartItem + i = 32) then
w := round(FFont.Width * SpaceWdth / 100);
memstr.WriteByte(w);
end;
end;
procedure WriteCharData;
@ -217,7 +226,7 @@ procedure TRBFFontConverter.SaveToFile(AFilename: String);
i, w, h, wmax: Integer;
b: Byte = 0;
begin
wmax := ((FFont.Width + 7) div 8) * 8 - 1;
wmax := ((FFont.Width + Spacing + 7) div 8) * 8 - 1;
for i := 0 to FFont.FontLength - 1 do
for h := 0 to FFont.Height - 1 do

View File

@ -710,6 +710,12 @@
---
### `v2.1.2.84` `2024.06.04`
1. Добавлена опция "Ширина пробела" для экспорта шрифта в RBF.
---
# Идеи и планы
Идеи для расширения функционала. Намеченные планы.