mirror of
https://github.com/Garhoogin/NitroPaint.git
synced 2025-06-18 14:25:31 -04:00
Add option to generate a glyph range
This commit is contained in:
parent
977c4c8cd2
commit
63acfd3b09
Binary file not shown.
@ -1437,6 +1437,51 @@ static void NftrViewerGenerateGlyphsForWholeFont(NFTRVIEWERDATA *data) {
|
||||
}
|
||||
}
|
||||
|
||||
static void NftrViewerGenerateGlyphRange(NFTRVIEWERDATA *data) {
|
||||
if (!NftrViewerSelectFontDialog(data)) return;
|
||||
|
||||
//get range
|
||||
uint16_t defCP = 0;
|
||||
int inputCP1 = NftrViewerPromptCharacter(data, L"Enter First Character", L"Enter a character or code point:", defCP);
|
||||
if (inputCP1 == -1) return; // exit
|
||||
|
||||
int inputCP2 = NftrViewerPromptCharacter(data, L"Enter Last Character", L"Enter a character or code point:", defCP);
|
||||
if (inputCP2 == -1) return; // exit
|
||||
|
||||
//check bounds (swap)
|
||||
if (inputCP1 > inputCP2) {
|
||||
int temp = inputCP1;
|
||||
inputCP1 = inputCP2;
|
||||
inputCP2 = temp;
|
||||
}
|
||||
|
||||
//find first glyph with CP >= inputCP1
|
||||
int glyphStart = -1, nGlyph = 0;
|
||||
for (int i = 0; i < data->nftr.nGlyph; i++) {
|
||||
|
||||
//starting glyph
|
||||
if (glyphStart == -1 && data->nftr.glyphs[i].cp >= (uint16_t) inputCP1) {
|
||||
glyphStart = i;
|
||||
}
|
||||
|
||||
//increase count
|
||||
if (glyphStart != -1 && data->nftr.glyphs[i].cp <= (uint16_t) inputCP2) {
|
||||
nGlyph++;
|
||||
}
|
||||
}
|
||||
|
||||
if (glyphStart != -1) {
|
||||
NftrViewerGenerateGlyphsFromFont(data, &data->nftr.glyphs[glyphStart], nGlyph);
|
||||
NftrViewerCacheInvalidateAll(data);
|
||||
InvalidateRect(data->hWndGlyphList, NULL, TRUE);
|
||||
|
||||
NFTR_GLYPH *cur = NftrViewerGetCurrentGlyph(data);
|
||||
if (cur != NULL) {
|
||||
NftrViewerSetCurrentGlyphByCodePoint(data, cur->cp, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void NftrViewerNewGlyphRange(NFTRVIEWERDATA *data) {
|
||||
uint16_t defCP = 0;
|
||||
HWND hWndMain = getMainWindow(data->hWnd);
|
||||
@ -1544,6 +1589,10 @@ static void NftrViewerOnMenuCommand(NFTRVIEWERDATA *data, int idMenu) {
|
||||
case ID_FONTMENU_NEWGLYPHRANGE:
|
||||
NftrViewerNewGlyphRange(data);
|
||||
break;
|
||||
case ID_FONTMENU2_GENERATEGLYPHRANGE:
|
||||
case ID_FONTMENU_GENERATEGLYPHRANGE:
|
||||
NftrViewerGenerateGlyphRange(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,13 +217,15 @@
|
||||
#define ID_FONTMENU_GENERATEALL 40229
|
||||
#define ID_FONTMENU_NEWGLYPHRANGE 40230
|
||||
#define ID_FONTMENU2_NEWGLYPHRANGE 40231
|
||||
#define ID_FONTMENU2_GENERATEGLYPHRANGE 40232
|
||||
#define ID_FONTMENU_GENERATEGLYPHRANGE 40233
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 111
|
||||
#define _APS_NEXT_COMMAND_VALUE 40232
|
||||
#define _APS_NEXT_COMMAND_VALUE 40234
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user