13 Commits
v2.9 ... main

Author SHA1 Message Date
6c860943a5 mctext lib fix 2025-07-19 09:02:49 +03:00
1852c697fc mctext lib update 2025-07-19 08:11:56 +03:00
Anton Mukhin
e76132cadb Update Readme.md 2025-07-18 17:57:19 +03:00
Anton Mukhin
5948948eee Update Readme.md 2025-07-18 17:55:37 +03:00
Anton Mukhin
c4067410c5 Little readme.md update 2025-07-18 17:39:23 +03:00
fe63d1bfab TODO features:
Application:
V Export comments now respects "Code in Hex" checkbox on the main form

Bugs:
V Frame modified flag persists when switching to another frame after rejected to save previous frame
V Ctrl-C, Ctrl-V doesn't work in the Note editbox because it tries to copy/paste the frame!
V Post "Backslash" instead of \ in comments
2025-07-17 02:21:41 +03:00
Anton Mukhin
dd3309d8ea Update TODO 2025-07-15 14:49:16 +03:00
Anton Mukhin
8efbd4da55 Updated TODO (found another bug) 2025-07-15 14:27:39 +03:00
Anton Mukhin
6a6d8f3e68 Update TODO (found a bug) 2025-07-15 14:23:47 +03:00
Anton Mukhin
a7d052e799 fonts.h and fonts.c example for the library 2025-07-14 17:31:11 +03:00
Anton Mukhin
ec9fbc4250 Update TODO.txt 2025-07-14 11:53:22 +03:00
Anton Mukhin
2e217c9a9e Remove old format examples 2025-07-11 10:14:56 +03:00
Anton Mukhin
d10da7cb20 My logo as example 2025-07-09 18:44:42 +03:00
22 changed files with 453 additions and 83 deletions

View File

@@ -233,7 +233,12 @@ namespace McBitFont {
if (com && lines != 1 && fcount > 1) {
// Comments enabled and other than "1 symbol per line" selected
// Print a symbol comment before its data
output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code);
string character = f.code switch {
92 => "Backslash",
_ => mainForm.DecodeSymbol(f.code),
};
string code = mainForm.chkHexCodes.Checked ? "0x" + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper() : f.code.ToString();
output += " // " + code + " --> " + character;
if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")";
output += "\n";
}
@@ -371,7 +376,12 @@ namespace McBitFont {
if (!f.Equals(flast) && f.width > 0) output += ",";
if (com && fcount > 1) {
//...with a comment
output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code);
string character = f.code switch {
92 => "Backslash",
_ => mainForm.DecodeSymbol(f.code),
};
string code = mainForm.chkHexCodes.Checked ? "0x" + Convert.ToString(f.code, 16).PadLeft(2, '0').ToUpper() : f.code.ToString();
output += " // " + code + " --> " + character;
if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")";
}
output += "\n";

View File

@@ -1216,13 +1216,13 @@
//
cmBaseline.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmiTopline, tsmiMidline, tsmiBaseline });
cmBaseline.Name = "cmBaseline";
cmBaseline.Size = new System.Drawing.Size(181, 92);
cmBaseline.Size = new System.Drawing.Size(121, 70);
//
// tsmiTopline
//
tsmiTopline.Image = Properties.Resources.fam_top;
tsmiTopline.Name = "tsmiTopline";
tsmiTopline.Size = new System.Drawing.Size(180, 22);
tsmiTopline.Size = new System.Drawing.Size(120, 22);
tsmiTopline.Text = "Top line";
tsmiTopline.ToolTipText = "Set top base line";
tsmiTopline.Click += tsmiTopline_Click;
@@ -1231,7 +1231,7 @@
//
tsmiMidline.Image = Properties.Resources.fam_mid;
tsmiMidline.Name = "tsmiMidline";
tsmiMidline.Size = new System.Drawing.Size(180, 22);
tsmiMidline.Size = new System.Drawing.Size(120, 22);
tsmiMidline.Text = "Mid line";
tsmiMidline.ToolTipText = "Set middle base line";
tsmiMidline.Click += tsmiMidline_Click;
@@ -1240,7 +1240,7 @@
//
tsmiBaseline.Image = Properties.Resources.fam_base;
tsmiBaseline.Name = "tsmiBaseline";
tsmiBaseline.Size = new System.Drawing.Size(180, 22);
tsmiBaseline.Size = new System.Drawing.Size(120, 22);
tsmiBaseline.Text = "Base line";
tsmiBaseline.ToolTipText = "Set bottom (base) line";
tsmiBaseline.Click += tsmiBaseline_Click;
@@ -1358,7 +1358,6 @@
private System.Windows.Forms.ToolStripMenuItem tsmiMakeVarWidth;
private System.Windows.Forms.ToolStripMenuItem importImageToolStripMenuItem;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckBox chkHexCodes;
private System.Windows.Forms.Button btnFill;
private System.Windows.Forms.ToolStripMenuItem FillToolStripMenuItem;
private System.Windows.Forms.CheckBox chkRectSelect;
@@ -1393,6 +1392,7 @@
private System.Windows.Forms.ToolStripMenuItem tsmiBaseline;
private System.Windows.Forms.ToolStripMenuItem tsmiMidline;
private System.Windows.Forms.ToolStripMenuItem tsmiTopline;
public System.Windows.Forms.CheckBox chkHexCodes;
}
}

View File

@@ -63,7 +63,6 @@ namespace McBitFont {
public FrameMiniature f;
public List<FrameMiniature> frames = new List<FrameMiniature>();
//private CanvasHistory history = new();
private ChangeHistory history;
private int cellSize = 10;
public int dotWidth, dotHeight;
@@ -73,7 +72,7 @@ namespace McBitFont {
public bool monospaced = false;
private bool modified = false;
private bool prjModified = false;
public const string version = "2.9";
public const string version = "2.10";
public string prjName = "Untitled";
public string prjFileName = "";
public int codepage = 1251;
@@ -83,6 +82,7 @@ namespace McBitFont {
private SetLines set_lines = SetLines.SL_None;
private Point selection1, selection2;
private Point[,] sidebarLocs = new Point[2, 3];
private bool frameClipboard = false;
public MainForm() {
@@ -475,6 +475,9 @@ namespace McBitFont {
var rectSel = chkRectSelect.Checked;
bool rectSelUpdated = false;
// Set input focus to minilist if any mouse button is held
if (!miniList.Focused && e.Button != MouseButtons.None) miniList.Focus();
// Drag with middle mouse button
if (vScroll.Enabled || hScroll.Enabled) {
if (mouseDownMiddle) {
@@ -1182,47 +1185,58 @@ namespace McBitFont {
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e) {
var bb = MessagePackSerializer.Serialize(CopyFrame(f, true));
DataObject clpbObj = new DataObject(clpbFormat.Name, bb);
Clipboard.SetDataObject(clpbObj, true);
if (tbFrameNote.Focused) {
tbFrameNote.Copy();
frameClipboard = false;
} else {
var bb = MessagePackSerializer.Serialize(CopyFrame(f, true));
DataObject clpbObj = new DataObject(clpbFormat.Name, bb);
Clipboard.SetDataObject(clpbObj, true);
frameClipboard = true;
}
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) {
// Try to read from clipboard
try {
IDataObject clpbObj = Clipboard.GetDataObject();
byte[] bb = (byte[])clpbObj.GetData(clpbFormat.Name);
fbuf = MessagePackSerializer.Deserialize<FrameMiniature>(bb);
}
catch {
return;
}
int di, dj, wmax, hmax, selw, selh;
if (chkRectSelect.Checked) {
di = selection1.X;
dj = selection1.Y;
selw = selection2.X - selection1.X + 1;
selh = selection2.Y - selection1.Y + 1;
wmax = fbuf.width > selw ? selw : fbuf.width;
hmax = fbuf.height > selh ? selh : fbuf.height;
} else {
di = 0;
dj = 0;
wmax = (fbuf.width > f.width) ? f.width : fbuf.width;
hmax = (fbuf.height > f.height) ? f.height : fbuf.height;
}
for (int i = 0; i < wmax; i++) {
for (int j = 0; j < hmax; j++) {
f.data[i + di, j + dj] = fbuf.data[i, j];
if (tbFrameNote.Focused) {
if (!frameClipboard) tbFrameNote.Paste();
} else if (frameClipboard) {
// Try to read from clipboard
try {
IDataObject clpbObj = Clipboard.GetDataObject();
byte[] bb = (byte[])clpbObj.GetData(clpbFormat.Name);
fbuf = MessagePackSerializer.Deserialize<FrameMiniature>(bb);
}
catch {
return;
}
}
history.Add(f);
CheckHistoryButtons();
dotPanel.Refresh();
SetModified();
int di, dj, wmax, hmax, selw, selh;
if (chkRectSelect.Checked) {
di = selection1.X;
dj = selection1.Y;
selw = selection2.X - selection1.X + 1;
selh = selection2.Y - selection1.Y + 1;
wmax = fbuf.width > selw ? selw : fbuf.width;
hmax = fbuf.height > selh ? selh : fbuf.height;
} else {
di = 0;
dj = 0;
wmax = (fbuf.width > f.width) ? f.width : fbuf.width;
hmax = (fbuf.height > f.height) ? f.height : fbuf.height;
}
for (int i = 0; i < wmax; i++) {
for (int j = 0; j < hmax; j++) {
f.data[i + di, j + dj] = fbuf.data[i, j];
}
}
history.Add(f);
CheckHistoryButtons();
dotPanel.Refresh();
SetModified();
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
@@ -1239,8 +1253,8 @@ namespace McBitFont {
if (modified) {
if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
SaveFrame();
SetModified(false);
}
SetModified(false);
}
}

View File

@@ -20,9 +20,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>icon_64.ico</ApplicationIcon>
<AssemblyVersion>2.9.0.0</AssemblyVersion>
<FileVersion>2.9.0.0</FileVersion>
<Version>$(VersionPrefix)2.9.0</Version>
<AssemblyVersion>2.10.0.0</AssemblyVersion>
<FileVersion>2.10.0.0</FileVersion>
<Version>$(VersionPrefix)2.10.0</Version>
<Copyright>Anton Mukhin</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -2,7 +2,11 @@
McFLY's Bit Font and Image Editor
Features:
Download in the [Releases](https://gitea.mcflyer.ru/McFLY/McBitFont/releases) section!
Library example instructions to implement to STM32 code: [mctext](STM32_HAL_Lib/README.md)
**Features:**
- Generate a project based on a font installed in the system
- Basic pixel manipulations: shift, flip, invert, etc...
- Import an image
@@ -12,14 +16,15 @@ Features:
- Export to a PNG image showing all the characters in a table
- Test your font in special dialog
Requires:
**Requires:**
- Windows 7+
- .NET 9
Some basic hints on the interface:
**Some basic hints on the interface:**
- Mouse 1 to mark a pixel black
- Mouse 2 to mark a pixel white
- Drag the mouse holding a button to draw pixels
- Hold middle mouse button to drag the canvas
- Hold Shift to constrain painting horizontally
- Hold Ctrl to constrain painting vertically
- Mouse Scroll to scroll up and down
@@ -28,10 +33,6 @@ Some basic hints on the interface:
- Alt + Scroll to change painting brush size
- When Rectangle selection tool is active hold Ctrl+Alt to temporary disable it to be able to draw
Download in the [Releases](https://gitea.mcflyer.ru/McFLY/McBitFont/releases) section!
Library example instructions to implement to STM32 code: [mctext](STM32_HAL_Lib/README.md)
#### Important:
**Since v2.0 new save file format is implemented. You can use [McBitFont v1.7](https://gitea.mcflyer.ru/McFLY/McBitFont/releases/tag/v1.7) to convert old saved files to the new format.**

285
STM32_HAL_Lib/fonts.c Normal file
View File

@@ -0,0 +1,285 @@
/*
ST7565 LCD library
Anton Mukhin, 2023
*/
#include <fonts.h>
/* Font header map:
uint8_t packed; // Is it a packed font?
uint8_t width; // Font width in pixels
uint8_t height; // Font height in pixels
uint8_t space; // Space between characters
uint8_t first; // First character code
uint8_t last; // Last character code
*/
const uint8_t font_5x7_vw[] = {
// Meta header
1, // Is it a packed font?
0, // Font width in pixels; 0 - variable width
7, // Font height in pixels
1, // Font space (between symbols) in pixels
0, // First character code
255, // Last character code
// Data:
0x00, // 0 -->
0x05, 0xff, 0xff, 0xff, 0xff, 0x07, // 1 -->
0x05, 0xff, 0x60, 0x30, 0xf8, 0x07, // 2 -->
0x00, // 3 -->
0x00, // 4 -->
0x00, // 5 -->
0x00, // 6 -->
0x00, // 7 -->
0x05, 0x0c, 0x0f, 0xcf, 0xc3, 0x00, // 8 -->
0x05, 0x08, 0x96, 0x8f, 0x85, 0x00, // 9 -->
0x05, 0x08, 0xa4, 0x1f, 0x89, 0x00, // 10 -->
0x05, 0x22, 0x0a, 0x82, 0x22, 0x02, // 11 -->
0x05, 0x10, 0x0c, 0x07, 0x03, 0x01, // 12 -->
0x05, 0x3e, 0x9f, 0xcf, 0xe7, 0x03, // 13 -->
0x05, 0x08, 0x8e, 0x8f, 0x83, 0x00, // 14 -->
0x05, 0x1c, 0x9f, 0xcf, 0xc7, 0x01, // 15 -->
0x18, 0x1c, 0x0e, 0x87, 0xc3, 0xe1, 0xf8, 0xfe, 0xff, 0xbf, 0x48, 0x04, 0x00, 0xfc, 0xff, 0x7f, 0x1f, 0x87, 0xc3, 0xe1, 0x70, 0x38, // 16 --> Not connected
0x18, 0x1c, 0x0e, 0x87, 0xe3, 0xfb, 0xff, 0x83, 0xff, 0x60, 0xb7, 0x3b, 0xfe, 0x8f, 0xbb, 0xdd, 0xf5, 0xdf, 0xc7, 0xe1, 0x70, 0x38, // 17 --> IDC
0x18, 0x1c, 0xdf, 0x7f, 0xb8, 0xff, 0x5f, 0xa7, 0xeb, 0xff, 0x79, 0x1d, 0xfc, 0xaf, 0xab, 0xeb, 0x7f, 0xb4, 0xda, 0xfe, 0xfb, 0x38, // 18 --> RS485
0x0a, 0x0c, 0x06, 0x00, 0xc0, 0x60, 0x00, 0x00, 0x0c, 0x06, // 19 -->
0x00, // 20 -->
0x00, // 21 -->
0x00, // 22 -->
0x00, // 23 -->
0x09, 0xc2, 0x70, 0xd4, 0x09, 0xe0, 0x48, 0xfe, 0x10, // 24 -->
0x09, 0x00, 0xe1, 0x1f, 0x08, 0x38, 0x15, 0x8b, 0x39, // 25 -->
0x00, // 26 -->
0x00, // 27 -->
0x00, // 28 -->
0x00, // 29 -->
0x00, // 30 -->
0x00, // 31 -->
0x01, 0x00, // 32 -->
0x01, 0x5f, // 33 --> !
0x03, 0x07, 0xc0, 0x01, // 34 --> "
0x05, 0x94, 0x3f, 0xe5, 0x4f, 0x01, // 35 --> #
0x05, 0x24, 0xd5, 0x5f, 0x25, 0x01, // 36 --> $
0x05, 0xa3, 0x09, 0x82, 0x2c, 0x06, // 37 --> %
0x05, 0xb6, 0x64, 0x55, 0x04, 0x05, // 38 --> &
0x02, 0x85, 0x01, // 39 --> '
0x02, 0xbe, 0x20, // 40 --> (
0x02, 0x41, 0x1f, // 41 --> )
0x05, 0x14, 0x84, 0x0f, 0x41, 0x01, // 42 --> *
0x05, 0x08, 0x84, 0x0f, 0x81, 0x00, // 43 --> +
0x02, 0x50, 0x18, // 44 --> ,
0x05, 0x08, 0x04, 0x02, 0x81, 0x00, // 45 --> -
0x02, 0x60, 0x30, // 46 --> .
0x05, 0x20, 0x08, 0x82, 0x20, 0x00, // 47 --> /
0x05, 0xbe, 0x68, 0xb2, 0xe8, 0x03, // 48 --> 0
0x05, 0x00, 0xe1, 0x1f, 0x08, 0x00, // 49 --> 1
0x05, 0xc2, 0x70, 0x34, 0x69, 0x04, // 50 --> 2
0x05, 0xa1, 0x60, 0x71, 0x19, 0x03, // 51 --> 3
0x05, 0x18, 0x8a, 0xe4, 0x0f, 0x01, // 52 --> 4
0x05, 0xa7, 0x62, 0xb1, 0x98, 0x03, // 53 --> 5
0x05, 0x3c, 0x65, 0x32, 0x09, 0x03, // 54 --> 6
0x05, 0x83, 0x40, 0x3c, 0x71, 0x00, // 55 --> 7
0x05, 0xb6, 0x64, 0x32, 0x69, 0x03, // 56 --> 8
0x05, 0x86, 0x64, 0x32, 0xe5, 0x01, // 57 --> 9
0x02, 0x36, 0x1b, // 58 --> :
0x02, 0x56, 0x1b, // 59 --> ;
0x04, 0x08, 0x8a, 0x28, 0x08, // 60 --> <
0x05, 0x14, 0x0a, 0x85, 0x42, 0x01, // 61 --> =
0x04, 0x41, 0x11, 0x05, 0x01, // 62 --> >
0x05, 0x82, 0x40, 0x34, 0x61, 0x00, // 63 --> ?
0x05, 0xb2, 0x64, 0x3e, 0xe8, 0x03, // 64 --> @
0x05, 0xfe, 0x48, 0x24, 0xe2, 0x07, // 65 --> A
0x05, 0xff, 0x64, 0x32, 0x69, 0x03, // 66 --> B
0x05, 0xbe, 0x60, 0x30, 0x28, 0x02, // 67 --> C
0x05, 0xff, 0x60, 0x50, 0xc4, 0x01, // 68 --> D
0x05, 0xff, 0x64, 0x32, 0x19, 0x04, // 69 --> E
0x05, 0xff, 0x44, 0x22, 0x11, 0x00, // 70 --> F
0x05, 0xbe, 0x60, 0x32, 0xa9, 0x07, // 71 --> G
0x05, 0x7f, 0x04, 0x02, 0xf1, 0x07, // 72 --> H
0x03, 0xc1, 0x7f, 0x10, // 73 --> I
0x05, 0x20, 0x60, 0xf0, 0x17, 0x00, // 74 --> J
0x05, 0x7f, 0x04, 0x45, 0x14, 0x04, // 75 --> K
0x05, 0x7f, 0x20, 0x10, 0x08, 0x04, // 76 --> L
0x05, 0x7f, 0x01, 0x43, 0xf0, 0x07, // 77 --> M
0x05, 0x7f, 0x02, 0x02, 0xf2, 0x07, // 78 --> N
0x05, 0xbe, 0x60, 0x30, 0xe8, 0x03, // 79 --> O
0x05, 0xff, 0x44, 0x22, 0x61, 0x00, // 80 --> P
0x05, 0xbe, 0x60, 0x34, 0xe4, 0x05, // 81 --> Q
0x05, 0xff, 0x44, 0x26, 0x65, 0x04, // 82 --> R
0x05, 0xc6, 0x64, 0x32, 0x19, 0x03, // 83 --> S
0x05, 0x81, 0xc0, 0x3f, 0x10, 0x00, // 84 --> T
0x05, 0x3f, 0x20, 0x10, 0xf8, 0x03, // 85 --> U
0x05, 0x1f, 0x10, 0x10, 0xf4, 0x01, // 86 --> V
0x05, 0x3f, 0x20, 0x0e, 0xf8, 0x03, // 87 --> W
0x05, 0x63, 0x0a, 0x82, 0x32, 0x06, // 88 --> X
0x05, 0x07, 0x04, 0x1c, 0x71, 0x00, // 89 --> Y
0x05, 0xe1, 0x68, 0xb2, 0x38, 0x04, // 90 --> Z
0x02, 0xff, 0x20, // 91 --> [
0x05, 0x02, 0x02, 0x02, 0x02, 0x02, // 92 --> backslash
0x02, 0xc1, 0x3f, // 93 --> ]
0x03, 0x04, 0x01, 0x01, // 94 --> ^
0x05, 0x40, 0x20, 0x10, 0x08, 0x04, // 95 --> _
0x03, 0x01, 0x01, 0x01, // 96 --> `
0x04, 0x20, 0x2a, 0x15, 0x0f, // 97 --> a
0x04, 0x7f, 0x24, 0x11, 0x07, // 98 --> b
0x04, 0x38, 0x22, 0x11, 0x04, // 99 --> c
0x04, 0x38, 0x22, 0xf2, 0x0f, // 100 --> d
0x04, 0x38, 0x2a, 0x15, 0x03, // 101 --> e
0x04, 0x08, 0x7f, 0x42, 0x00, // 102 --> f
0x04, 0x0c, 0xa9, 0xd4, 0x07, // 103 --> g
0x04, 0x7f, 0x04, 0x01, 0x0f, // 104 --> h
0x03, 0xc4, 0x3e, 0x10, // 105 --> i
0x04, 0x20, 0x20, 0xb1, 0x07, // 106 --> j
0x04, 0x7f, 0x08, 0x8a, 0x08, // 107 --> k
0x03, 0xc1, 0x3f, 0x10, // 108 --> l
0x05, 0x7c, 0x02, 0x86, 0x80, 0x07, // 109 --> m
0x04, 0x7c, 0x04, 0x01, 0x0f, // 110 --> n
0x04, 0x38, 0x22, 0x11, 0x07, // 111 --> o
0x04, 0x7c, 0x0a, 0x05, 0x01, // 112 --> p
0x04, 0x08, 0x0a, 0x86, 0x0f, // 113 --> q
0x04, 0x7c, 0x04, 0x01, 0x01, // 114 --> r
0x04, 0x48, 0x2a, 0x15, 0x04, // 115 --> s
0x04, 0x84, 0x1f, 0x11, 0x04, // 116 --> t
0x04, 0x3c, 0x20, 0x88, 0x0f, // 117 --> u
0x05, 0x1c, 0x10, 0x10, 0xc4, 0x01, // 118 --> v
0x05, 0x3c, 0x20, 0x0e, 0xc8, 0x03, // 119 --> w
0x04, 0x6c, 0x08, 0x84, 0x0d, // 120 --> x
0x04, 0x0c, 0x28, 0x94, 0x07, // 121 --> y
0x04, 0x64, 0x3a, 0x97, 0x09, // 122 --> z
0x03, 0x08, 0x5b, 0x10, // 123 --> {
0x01, 0x7f, // 124 --> |
0x03, 0x41, 0x1b, 0x02, // 125 --> }
0x05, 0x08, 0x02, 0x03, 0x41, 0x00, // 126 --> ~
0x00, // 127 --> 
0x05, 0x81, 0x7f, 0x2a, 0x19, 0x03, // 128 --> <20>
0x00, // 129 --> <20>
0x00, // 130 --> <20>
0x00, // 131 --> <20>
0x03, 0x70, 0x00, 0x1c, // 132 --> <20>
0x05, 0x40, 0x00, 0x10, 0x00, 0x04, // 133 --> <20>
0x05, 0x04, 0xc2, 0x9f, 0x40, 0x00, // 134 --> <20>
0x05, 0x14, 0xca, 0x9f, 0x42, 0x01, // 135 --> <20>
0x05, 0xbe, 0x6a, 0x35, 0x28, 0x02, // 136 --> <20>
0x05, 0xa8, 0x7f, 0x2a, 0x65, 0x00, // 137 --> <20>
0x00, // 138 --> <20>
0x03, 0x10, 0x14, 0x11, // 139 --> <20>
0x00, // 140 --> <20>
0x05, 0x04, 0xc1, 0x47, 0x40, 0x00, // 141 --> <20>
0x05, 0x10, 0x10, 0x1f, 0x04, 0x01, // 142 --> <20>
0x05, 0x08, 0x8e, 0x0a, 0x81, 0x00, // 143 --> <20>
0x05, 0x08, 0x84, 0x8a, 0x83, 0x00, // 144 --> <20>
0x00, // 145 --> <20>
0x00, // 146 --> <20>
0x00, // 147 --> <20>
0x03, 0x07, 0xc0, 0x01, // 148 --> <20>
0x03, 0x14, 0x04, 0x05, // 149 --> <20>
0x03, 0x08, 0x04, 0x02, // 150 --> <20>
0x05, 0x08, 0x04, 0x02, 0x81, 0x00, // 151 --> <20>
0x00, // 152 -->
0x00, // 153 --> <20>
0x00, // 154 --> <20>
0x03, 0x22, 0x0a, 0x02, // 155 --> <20>
0x00, // 156 --> <20>
0x05, 0x78, 0x30, 0x14, 0x49, 0x00, // 157 --> <20>
0x05, 0x04, 0x24, 0x14, 0x8c, 0x07, // 158 --> <20>
0x05, 0x90, 0x44, 0x61, 0xf0, 0x00, // 159 --> <20>
0x05, 0x8f, 0x41, 0x21, 0x01, 0x01, // 160 --> <20>
0x00, // 161 --> <20>
0x00, // 162 --> <20>
0x00, // 163 --> <20>
0x05, 0x5d, 0x91, 0x48, 0xd4, 0x05, // 164 --> <20>
0x00, // 165 --> <20>
0x01, 0x77, // 166 --> <20>
0x00, // 167 --> <20>
0x05, 0xfe, 0xa5, 0x72, 0x29, 0x04, // 168 --> <20>
0x05, 0xbe, 0xf1, 0x7a, 0xed, 0x03, // 169 --> <20>
0x05, 0xbe, 0x64, 0x32, 0x29, 0x02, // 170 --> <20>
0x05, 0x08, 0x8a, 0x8a, 0x22, 0x02, // 171 --> <20>
0x05, 0x08, 0x04, 0x02, 0x81, 0x03, // 172 --> <20>
0x00, // 173 --> <20>
0x05, 0x9e, 0x50, 0x6d, 0xe5, 0x01, // 174 --> <20>
0x05, 0x80, 0x00, 0x3f, 0x00, 0x00, // 175 --> <20>
0x05, 0x83, 0x1d, 0x91, 0x88, 0x02, // 176 --> <20>
0x03, 0x24, 0x17, 0x09, // 177 --> <20>
0x00, // 178 --> <20>
0x00, // 179 --> <20>
0x00, // 180 --> <20>
0x05, 0x7c, 0x08, 0x08, 0xc4, 0x03, // 181 --> <20>
0x05, 0x86, 0x7f, 0xe0, 0x1f, 0x00, // 182 --> <20>
0x03, 0x1c, 0x0e, 0x07, // 183 --> <20>
0x04, 0x39, 0x6a, 0x15, 0x03, // 184 --> <20>
0x04, 0x7c, 0x0c, 0x8c, 0x0f, // 185 --> <20>
0x04, 0x38, 0x2a, 0x95, 0x08, // 186 --> <20>
0x05, 0x22, 0x8a, 0x8a, 0x82, 0x00, // 187 --> <20>
0x05, 0xc1, 0x60, 0x37, 0x18, 0x04, // 188 --> <20>
0x05, 0xc1, 0x6e, 0xb0, 0x1b, 0x04, // 189 --> <20>
0x05, 0xdd, 0x60, 0x37, 0xd8, 0x05, // 190 --> <20>
0x05, 0x00, 0x02, 0x9c, 0x00, 0x00, // 191 --> <20>
0x05, 0xfe, 0x48, 0x24, 0xe2, 0x07, // 192 --> <20>
0x05, 0xff, 0x64, 0x32, 0x39, 0x03, // 193 --> <20>
0x05, 0xff, 0x64, 0x32, 0x69, 0x03, // 194 --> <20>
0x05, 0xff, 0x40, 0x20, 0x30, 0x00, // 195 --> <20>
0x05, 0x60, 0x5f, 0xe8, 0x07, 0x06, // 196 --> <20>
0x05, 0xff, 0x64, 0x32, 0x19, 0x04, // 197 --> <20>
0x05, 0x77, 0xc4, 0x1f, 0x71, 0x07, // 198 --> <20>
0x05, 0xc1, 0x64, 0x32, 0x69, 0x03, // 199 --> <20>
0x05, 0x7f, 0x08, 0x82, 0xf0, 0x07, // 200 --> <20>
0x05, 0xfe, 0x90, 0x24, 0xe1, 0x07, // 201 --> <20>
0x05, 0x7f, 0x04, 0x45, 0x14, 0x04, // 202 --> <20>
0x05, 0x40, 0x5f, 0x20, 0xf0, 0x07, // 203 --> <20>
0x05, 0x7f, 0x01, 0x43, 0xf0, 0x07, // 204 --> <20>
0x05, 0x7f, 0x04, 0x02, 0xf1, 0x07, // 205 --> <20>
0x05, 0xbe, 0x60, 0x30, 0xe8, 0x03, // 206 --> <20>
0x05, 0xff, 0x40, 0x20, 0xf0, 0x07, // 207 --> <20>
0x05, 0xff, 0x44, 0x22, 0x61, 0x00, // 208 --> <20>
0x05, 0xbe, 0x60, 0x30, 0x28, 0x02, // 209 --> <20>
0x05, 0x81, 0xc0, 0x3f, 0x10, 0x00, // 210 --> <20>
0x05, 0x27, 0x24, 0x12, 0xf9, 0x03, // 211 --> <20>
0x05, 0x1c, 0xd1, 0x5f, 0xc4, 0x01, // 212 --> <20>
0x05, 0x63, 0x1a, 0x82, 0x32, 0x06, // 213 --> <20>
0x05, 0x3f, 0x10, 0xe8, 0x07, 0x06, // 214 --> <20>
0x05, 0x07, 0x04, 0x02, 0xf1, 0x07, // 215 --> <20>
0x05, 0x7f, 0xe0, 0x1f, 0xf8, 0x07, // 216 --> <20>
0x05, 0x3f, 0xd0, 0x0f, 0xf4, 0x07, // 217 --> <20>
0x05, 0x81, 0x3f, 0x12, 0x09, 0x03, // 218 --> <20>
0x05, 0x7f, 0x24, 0x12, 0xf6, 0x07, // 219 --> <20>
0x05, 0x7f, 0x24, 0x12, 0x09, 0x03, // 220 --> <20>
0x05, 0xa2, 0x60, 0x32, 0xe9, 0x03, // 221 --> <20>
0x05, 0x7f, 0x84, 0x2f, 0xe8, 0x03, // 222 --> <20>
0x05, 0xc6, 0x54, 0x26, 0xf1, 0x07, // 223 --> <20>
0x04, 0x20, 0x2a, 0x15, 0x0f, // 224 --> <20>
0x04, 0xbe, 0x62, 0x11, 0x07, // 225 --> <20>
0x04, 0x7c, 0x2a, 0x16, 0x04, // 226 --> <20>
0x03, 0x7c, 0x02, 0x01, // 227 --> <20>
0x05, 0x60, 0x1c, 0x89, 0x07, 0x06, // 228 --> <20>
0x04, 0x38, 0x2a, 0x15, 0x03, // 229 --> <20>
0x05, 0x6c, 0x08, 0x1f, 0xc2, 0x06, // 230 --> <20>
0x04, 0x44, 0x2a, 0x15, 0x05, // 231 --> <20>
0x04, 0x7c, 0x10, 0x84, 0x0f, // 232 --> <20>
0x04, 0x7c, 0x90, 0xa4, 0x0f, // 233 --> <20>
0x04, 0x7c, 0x08, 0x8a, 0x08, // 234 --> <20>
0x04, 0x40, 0x1c, 0x81, 0x0f, // 235 --> <20>
0x05, 0x7c, 0x04, 0x04, 0xc1, 0x07, // 236 --> <20>
0x04, 0x7c, 0x08, 0x84, 0x0f, // 237 --> <20>
0x04, 0x38, 0x22, 0x11, 0x07, // 238 --> <20>
0x04, 0x7c, 0x02, 0x81, 0x0f, // 239 --> <20>
0x04, 0x7c, 0x0a, 0x05, 0x01, // 240 --> <20>
0x04, 0x38, 0x22, 0x11, 0x04, // 241 --> <20>
0x03, 0x04, 0x3e, 0x01, // 242 --> <20>
0x04, 0x0c, 0x28, 0x94, 0x07, // 243 --> <20>
0x05, 0x10, 0x14, 0x1f, 0x05, 0x01, // 244 --> <20>
0x04, 0x6c, 0x08, 0x84, 0x0d, // 245 --> <20>
0x04, 0x3c, 0x10, 0x0f, 0x0c, // 246 --> <20>
0x04, 0x0c, 0x08, 0x84, 0x0f, // 247 --> <20>
0x05, 0x7c, 0x20, 0x1f, 0xc8, 0x07, // 248 --> <20>
0x05, 0x3c, 0x10, 0x0f, 0xc4, 0x07, // 249 --> <20>
0x04, 0x04, 0x3e, 0x14, 0x04, // 250 --> <20>
0x05, 0x7c, 0x28, 0x14, 0xc4, 0x07, // 251 --> <20>
0x04, 0x7c, 0x28, 0x14, 0x04, // 252 --> <20>
0x04, 0x44, 0x2a, 0x15, 0x07, // 253 --> <20>
0x05, 0x7c, 0x08, 0x8e, 0x88, 0x03, // 254 --> <20>
0x04, 0x48, 0x1a, 0x85, 0x0f // 255 --> <20>
};

27
STM32_HAL_Lib/fonts.h Normal file
View File

@@ -0,0 +1,27 @@
/*
ST7565 LCD Font library
Anton Mukhin, 2023
*/
#ifndef INC_FONTS_H_
#define INC_FONTS_H_
#include <stdint.h>
#define FONT_HEADER 6
/* Font header map:
uint8_t packed; // Is it a packed font?
uint8_t width; // Font width in pixels
uint8_t height; // Font height in pixels
uint8_t space; // Space between characters
uint8_t first; // First character code
uint8_t last; // Last character code
*/
extern const uint8_t font_5x7_vw[];
#endif /* INC_FONTS_H_ */

View File

@@ -2,7 +2,7 @@
* mctext.c
*
* Created on: May 16, 2025
* Author: User
* Author: Anton Mukhin
*/
@@ -15,8 +15,10 @@ void (*mct_SetPixel)(uint8_t, uint8_t, uint8_t) = ST7565_SetPixel;
//=================================================================================//
// Draw a single character. Returns width of drawn character
uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp) {
uint8_t mct_CharTS(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp, uint8_t scale) {
uint8_t pk = font[0]; // Is it a packed font?
uint8_t w = font[1]; // Font char width
uint8_t h = font[2]; // Font char height
@@ -25,10 +27,11 @@ uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const ui
uint8_t i, j, p, s, b, seg; // i-cur.column, j-cur.row of 8, p-rows of 8, s-height in cur.row of 8, b-cur.bit in cur.row, seg-byte.segment
uint8_t bps; // Bytes per symbol for packed fonts
uint16_t o; // Current offset
uint8_t sx, sy; // To paint scaled pixel
if (c < fc || c > lc) return 0;
if (x > LCDWIDTH) return 0;
if (y+h > LCDHEIGHT) return 0;
if (y + h * scale > LCDHEIGHT) return 0;
// Calc the offset for desired symbol
if (pk) { // The font is packed
@@ -51,11 +54,19 @@ uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const ui
bps = w*h/8; // Bytes per current symbol
if ((w*h)%8 > 0) bps++; // Correction for the last byte
b = 0; // bit indexer in "current" byte
for (i=0; i<w; i++) { // Going through columns
for (i=0; i<w*scale; i+=scale) { // Going through columns
if (x+i > LCDWIDTH) return i-1; // Check if we're out of display size
for (j=0; j<h; j++) { // Going through rows in column [i]
for (j=0; j<h*scale; j+=scale) { // Going through rows in column [i]
if (b == 0) seg = font[o];
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j, color); // Paint the pixel
if ((seg>>b) & 1) {
for (sx = 0; sx < scale; sx++)
for (sy = 0; sy < scale; sy++)
mct_SetPixel(x+i+sx, y+j+sy, color); // Paint the pixel
} else if (!transp) {
for (sx = 0; sx < scale; sx++)
for (sy = 0; sy < scale; sy++)
mct_SetPixel(x+i+sx, y+j+sy, !color); // Paint the background pixel
}
if (b < 7) b++; else {b = 0; o++;} // Track bits and bytes
}
}
@@ -74,22 +85,34 @@ uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const ui
}
// Draw the symbol
for (i=0; i<w; i++) { // Going through columns
for (i=0; i<w*scale; i+=scale) { // Going through columns
if (x+i > LCDWIDTH) return i-1; // Check if we're out of display size
for (j=0; j<p; j++) { // Going through bytes in single column
s = (h - j*8 >= 8) ? 8 : (h - j*8) % 8; // Clac the amount of pixels in current byte
seg = font[o];
for (b=0; b<s; b++) { // Going through the byte and paint the pixel if the bit is 1
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j*8+b, color);
else if (!transp) mct_SetPixel(x+i, y+j*8+b, !color);
if ((seg>>b) & 1) {
for (sx = 0; sx < scale; sx++)
for (sy = 0; sy < scale; sy++)
mct_SetPixel(x+i+sx, y+j*8*scale+b*scale+sy, color);
} else if (!transp) {
for (sx = 0; sx < scale; sx++)
for (sy = 0; sy < scale; sy++)
mct_SetPixel(x+i+sx, y+j*8*scale+b*scale+sy, !color);
}
}
o++;
}
//mct_SetPixel(x+i, y, color); // For testing purposes
}
}
return w;
return w*scale;
}
// Draw a single character. Not scaled
uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp) {
return mct_CharTS(x, y, c, color, font, transp, 1);
}
// Draw a single character. Transparent background. Returns width of drawn character
@@ -97,17 +120,22 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin
return mct_CharT(x, y, c, color, font, 1);
}
// Draw a string of characters
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) {
// Draw a string of characters. Transparency, Scale
void mct_StringTS(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font, uint8_t transp, uint8_t scale) {
uint8_t w = font[1]; // Font char width
uint8_t h = font[2]; // Font char height
uint8_t s = font[3]; // Font space between characters
if (y+h > LCDHEIGHT) return;
if (y+h*scale > LCDHEIGHT) return;
while (c[0] != 0) {
if (x+w > LCDWIDTH) return;
w = mct_Char(x, y, (unsigned char)*c, color, font);
//if (x+w > LCDWIDTH) return;
w = mct_CharTS(x, y, (unsigned char)*c, color, font, transp, scale);
c++;
x += w + s;
x += w + s*scale;
}
}
// Draw a string of characters
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) {
mct_StringTS(x, y, c, color, font, 1, 1);
}

View File

@@ -2,19 +2,27 @@
* mctext.h
*
* Created on: May 16, 2025
* Author: User
* Author: Anton Mukhin
*/
#ifndef INC_MCTEXT_H_
#define INC_MCTEXT_H_
#include "stm32f1xx_hal.h"
#include "stm32g0xx_hal.h"
// Draw a single character. Returns width of drawn character
uint8_t mct_CharTS(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp, uint8_t scale);
// Draw a single character. Not scaled
uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp);
// Draw a single character. Transparent background. Returns width of drawn character
uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font);
// Draw a string of characters. Transparency, Scale
void mct_StringTS(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font, uint8_t transp, uint8_t scale);
// Draw a string of characters
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font);

View File

@@ -1,14 +1,11 @@
Application:
- Consider migrating to WPF in order to make DPI aware UI
V Special cursor to indicate baseline set
V Special cursor when dragging canvas with middle mouse button
V Export comments now respects "Code in Hex" checkbox on the main form
Functionality:
V Show note field in Export comments
V When Rectangle selection tool is active hold Ctrl+Alt to temporary disable it to be able to draw
V Frame screenshot can be copied to clipboard with some limitations (no transparency)
V Beside Baseline, also make top and mid lines
Bugs:
V Fixed "Frame modified" check. It leaves modified flag if user refused to save changes.
V Middle mouse button tries to change selection while dragging canvas with rectSelection tool active
V Frame modified flag persists when switching to another frame after rejected to save previous frame
V Ctrl-C, Ctrl-V doesn't work in the Note editbox because it tries to copy/paste the frame!
V Post "Backslash" instead of \ in comments

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.