mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
separate fonts in fontChain
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
a601d335ea
commit
d8dfe555d2
@ -4230,23 +4230,25 @@ InitTheme(
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
DBG("validate %d face\n", i);
|
||||
// DBG("validate %d face\n", i);
|
||||
textFace[i].valid = FALSE;
|
||||
}
|
||||
DBG("...done\n");
|
||||
/*
|
||||
NSVGfont *nextFont, *font = fontsDB;
|
||||
while (font) {
|
||||
nextFont = font->next;
|
||||
DBG("delete font %a\n", font->id);
|
||||
// DBG("...done\n");
|
||||
NSVGfontChain *fontChain = fontsDB;
|
||||
while (fontChain) {
|
||||
NSVGfont *font = fontChain->font;
|
||||
NSVGfontChain *nextChain = fontChain->next;
|
||||
if (font) {
|
||||
nsvg__deleteFont(font);
|
||||
DBG("...next\n");
|
||||
font = nextFont;
|
||||
fontChain->font = NULL;
|
||||
}
|
||||
DBG("...done\n");
|
||||
|
||||
FreePool(fontChain);
|
||||
fontChain = nextChain->next;
|
||||
}
|
||||
//as all font freed then free the chain
|
||||
fontsDB = NULL;
|
||||
|
||||
/*
|
||||
if (mainParser) {
|
||||
nsvg__deleteParser(mainParser);
|
||||
DBG("parser deleted\n");
|
||||
@ -4256,7 +4258,7 @@ InitTheme(
|
||||
row0TileSize = 144;
|
||||
row1TileSize = 64;
|
||||
if (FontImage != NULL) {
|
||||
DBG("free font image\n");
|
||||
// DBG("free font image\n"); //raster font
|
||||
egFreeImage (FontImage);
|
||||
FontImage = NULL;
|
||||
}
|
||||
@ -4265,7 +4267,7 @@ InitTheme(
|
||||
|
||||
// Free selection images which are not builtin icons
|
||||
for (i = 0; i < 6; i++) {
|
||||
DBG("free selection %d\n", i);
|
||||
// DBG("free selection %d\n", i);
|
||||
if (SelectionImages[i] != NULL) {
|
||||
if ((SelectionImages[i] != BuiltinIconTable[BUILTIN_SELECTION_SMALL].Image) &&
|
||||
(SelectionImages[i] != BuiltinIconTable[BUILTIN_SELECTION_BIG].Image)) {
|
||||
@ -4274,20 +4276,20 @@ InitTheme(
|
||||
SelectionImages[i] = NULL;
|
||||
}
|
||||
}
|
||||
DBG("...done\n");
|
||||
// DBG("...done\n");
|
||||
// Free banner which is not builtin icon
|
||||
if (Banner != NULL) {
|
||||
if (Banner != BuiltinIconTable[BUILTIN_ICON_BANNER].Image) {
|
||||
DBG("free banner\n");
|
||||
// DBG("free banner\n");
|
||||
egFreeImage (Banner);
|
||||
}
|
||||
Banner = NULL;
|
||||
}
|
||||
DBG("...done\n");
|
||||
// DBG("...done\n");
|
||||
//Free buttons images
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (Buttons[i] != NULL) {
|
||||
DBG("free button %d\n", i);
|
||||
// DBG("free button %d\n", i);
|
||||
egFreeImage(Buttons[i]);
|
||||
Buttons[i] = NULL;
|
||||
}
|
||||
@ -4298,22 +4300,22 @@ InitTheme(
|
||||
//here we have no access to Mouse
|
||||
|
||||
// Invalidate BuiltinIcons
|
||||
DBG ("Invalidating BuiltinIcons...\n");
|
||||
// DBG ("Invalidating BuiltinIcons...\n");
|
||||
for (i = 0; i < BUILTIN_ICON_COUNT; i++) {
|
||||
if (BuiltinIconTable[i].Image != NULL) {
|
||||
DBG("free builtin image %d\n", i);
|
||||
// DBG("free builtin image %d\n", i);
|
||||
egFreeImage (BuiltinIconTable[i].Image);
|
||||
BuiltinIconTable[i].Image = NULL;
|
||||
}
|
||||
}
|
||||
DBG("...done\n");
|
||||
// DBG("...done\n");
|
||||
while (GuiAnime != NULL) {
|
||||
GUI_ANIME *NextAnime = GuiAnime->Next;
|
||||
DBG("free anime %d\n", GuiAnime->ID);
|
||||
// DBG("free anime %d\n", GuiAnime->ID);
|
||||
FreeAnime (GuiAnime);
|
||||
GuiAnime = NextAnime;
|
||||
}
|
||||
DBG("...done\n");
|
||||
// DBG("...done\n");
|
||||
GetThemeTagSettings(NULL);
|
||||
|
||||
if (ThemesNum > 0 &&
|
||||
|
@ -760,7 +760,7 @@ VOID testSVG()
|
||||
FreePool(FileData);
|
||||
FileData = NULL;
|
||||
egFreeImage(NewImage);
|
||||
nsvg__deleteParser(p);
|
||||
// nsvg__deleteParser(p);
|
||||
nsvgDeleteRasterizer(rast);
|
||||
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ unsigned XImage::FromSVG(const CHAR8 *SVGData, UINTN FileDataLength, float scale
|
||||
nsvgRasterize(rast, SVGimage, 0.f, 0.f, Scale, Scale, (UINT8*)&PixelData[0], (int)Width, (int)Height, (int)Width * sizeof(PixelData[0]));
|
||||
FreePool(SVGimage);
|
||||
}
|
||||
nsvg__deleteParser(p);
|
||||
// nsvg__deleteParser(p); //can't delete raster until we make imageChain
|
||||
nsvgDeleteRasterizer(rast);
|
||||
FreePool(input);
|
||||
return 0;
|
||||
|
@ -609,7 +609,7 @@ void nsvg__deleteParser(NSVGparser* p)
|
||||
nsvg__deletePaths(p->plist);
|
||||
nsvg__deleteGradientData(p->gradients);
|
||||
// do not delete font here, as we free all fonts later by following fontsdb
|
||||
//nsvg__deleteFont(p->font);
|
||||
|
||||
nsvgDelete(p->image);
|
||||
if (p->cpts > 0 && p->pts) {
|
||||
FreePool(p->pts);
|
||||
@ -2820,7 +2820,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
text->y = y;
|
||||
text->fontSize = attr->fontFace->fontSize;
|
||||
text->fontStyle = attr->fontFace->fontStyle;
|
||||
memcpy(text->id, attr->id, 64);
|
||||
memcpy(text->id, attr->id, kMaxIDLength);
|
||||
text->fontFace = attr->fontFace;
|
||||
if (attr->hasFill == 1) {
|
||||
text->fontColor = attr->fillColor | ((int)(attr->fillOpacity * 255.f) << 24);
|
||||
@ -2836,15 +2836,20 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
}
|
||||
// DBG("required font %a required style=%c\n", text->fontFace->fontFamily, text->fontStyle);
|
||||
//if the font is not registered then we have to load new one
|
||||
NSVGfont *fontSVG = fontsDB;
|
||||
while (fontSVG) {
|
||||
// DBG("probe fontFamily=%a fontStyle=%c\n", fontSVG->fontFamily, fontSVG->fontStyle);
|
||||
NSVGfont *fontSVG = NULL;
|
||||
NSVGfontChain *fontChain = fontsDB;
|
||||
|
||||
while (fontChain) {
|
||||
fontSVG = fontChain->font;
|
||||
if (fontSVG) {
|
||||
// DBG("probe fontFamily=%a fontStyle=%c\n", fontSVG->fontFamily, fontSVG->fontStyle);
|
||||
if ((strcmp(fontSVG->fontFamily, text->fontFace->fontFamily) == 0) &&
|
||||
(fontSVG->fontStyle == text->fontStyle)) {
|
||||
// DBG("font %a found\n", fontSVG->fontFamily);
|
||||
// DBG("font %a found\n", fontSVG->fontFamily);
|
||||
break;
|
||||
}
|
||||
fontSVG = fontSVG->next;
|
||||
}
|
||||
fontChain = fontChain->next;
|
||||
}
|
||||
if (!fontSVG) { // font not found
|
||||
//then load it
|
||||
@ -2856,24 +2861,26 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
Status = egLoadFile(ThemeDir, PoolPrint(L"%a.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
|
||||
// DBG("font %a loaded status=%r\n", text->fontFace->fontFamily, Status);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
p1 = nsvgParse((CHAR8*)FileData, 72, 1.0f);
|
||||
p1 = nsvgParse((CHAR8*)FileData, 72, 1.0f); //later we will free parser p1
|
||||
if (!p1) {
|
||||
DBG("font %a not parsed\n", text->fontFace->fontFamily);
|
||||
} else {
|
||||
fontSVG = (__typeof__(fontSVG))AllocateCopyPool(sizeof(NSVGfont), p1->font);
|
||||
// DBG("font family %a parsed\n", fontSVG->fontFamily);
|
||||
fontSVG->next = fontsDB;
|
||||
fontsDB = fontSVG;
|
||||
text->font = fontSVG;
|
||||
fontChain = (__typeof__(fontChain))AllocatePool(sizeof(*fontChain));
|
||||
fontChain->font = fontSVG;
|
||||
fontChain->next = fontsDB;
|
||||
fontsDB = fontChain;
|
||||
text->font = fontSVG; //this is the same pointer as in fontChain but we will never free text->font. We will free fontChain
|
||||
}
|
||||
FreePool(FileData);
|
||||
FreePool(FileData); //after load
|
||||
FileData = NULL;
|
||||
} else {
|
||||
text->font = p->font; //else embedded if present
|
||||
text->font = p->font; //else embedded if present which is also double fontChain
|
||||
}
|
||||
} else {
|
||||
// DBG("set font for text %a\n", fontSVG->id);
|
||||
text->font = fontSVG;
|
||||
DBG("set found font %a\n", fontSVG->id);
|
||||
text->font = fontSVG; //the font found in fontChain
|
||||
}
|
||||
|
||||
//instead of embedded
|
||||
@ -2939,9 +2946,9 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
group = group->next;
|
||||
}
|
||||
}
|
||||
if (!text->font || !text->font->glyphs) {
|
||||
text->font = fontsDB;
|
||||
}
|
||||
// if (!text->font || !text->font->glyphs) {
|
||||
// text->font = fontsDB;
|
||||
// }
|
||||
|
||||
//add to head
|
||||
text->next = p->text;
|
||||
|
@ -153,7 +153,7 @@ typedef struct NSVGclip
|
||||
typedef struct NSVGshape NSVGshape;
|
||||
|
||||
typedef struct NSVGpattern {
|
||||
char id[64];
|
||||
char id[kMaxIDLength];
|
||||
int nx, ny; //repeat
|
||||
float width;
|
||||
float height;
|
||||
@ -191,7 +191,7 @@ typedef struct NSVGshape
|
||||
float miterLimit; // Miter limit
|
||||
float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
|
||||
float xform[6];
|
||||
NSVGpath* paths; // Linked list of paths in the image. One shape - one path.
|
||||
NSVGpath** pathsHandle; // Linked list of paths in the image. One shape - one path.
|
||||
NSVGgroup* group; // Pointer to parent group or NULL
|
||||
NSVGclip clip;
|
||||
struct NSVGshape* next; // Pointer to next shape, or NULL if last element.
|
||||
@ -216,6 +216,7 @@ typedef struct NSVGimage
|
||||
float realBounds[4];
|
||||
NSVGshape* shapes; // Linked list of shapes in the image.
|
||||
NSVGgroup* groups; // Linked list of all groups in the image
|
||||
NSVGpath* paths; // Linked list of paths in the image.
|
||||
BOOLEAN isFont;
|
||||
NSVGclipPath* clipPaths;
|
||||
} NSVGimage;
|
||||
@ -331,10 +332,10 @@ typedef struct NSVGglyph {
|
||||
} NSVGglyph;
|
||||
|
||||
typedef struct NSVGfont {
|
||||
char id[64];
|
||||
char id[kMaxIDLength];
|
||||
int horizAdvX;
|
||||
// --- font-face
|
||||
char fontFamily[64];
|
||||
char fontFamily[kMaxIDLength];
|
||||
float fontWeight; //usually 400 like stroke-width
|
||||
float fontSize; // 8,9,12,14...
|
||||
float unitsPerEm; //usually 1000
|
||||
@ -354,9 +355,14 @@ typedef struct NSVGfont {
|
||||
// -- glyphs
|
||||
NSVGglyph* missingGlyph;
|
||||
NSVGglyph* glyphs; // a chain
|
||||
struct NSVGfont* next;
|
||||
// struct NSVGfont* next;
|
||||
} NSVGfont;
|
||||
|
||||
typedef struct NSVGfontChain {
|
||||
NSVGfont *font;
|
||||
struct NSVGfontChain* next;
|
||||
} NSVGfontChain;
|
||||
|
||||
typedef struct textFaces {
|
||||
NSVGfont *font;
|
||||
UINT32 color;
|
||||
@ -367,7 +373,7 @@ typedef struct textFaces {
|
||||
extern textFaces textFace[]; //0-help 1-message 2-menu 3-test
|
||||
|
||||
typedef struct NSVGtext {
|
||||
char id[64];
|
||||
char id[kMaxIDLength];
|
||||
// char class[64];
|
||||
float x,y;
|
||||
float xform[6];
|
||||
@ -383,17 +389,19 @@ typedef struct NSVGtext {
|
||||
float strokeWidth;
|
||||
NSVGstyles* style;
|
||||
NSVGshape* shapes;
|
||||
NSVGpath* paths; //the paths for shapes. Shapes will have only handles
|
||||
struct NSVGtext *next;
|
||||
NSVGgroup* group;
|
||||
} NSVGtext;
|
||||
|
||||
typedef struct NSVGsymbol {
|
||||
char id[64];
|
||||
char id[kMaxIDLength];
|
||||
// float xform[6];
|
||||
float bounds[4];
|
||||
float viewBox[4];
|
||||
NSVGshape* shapes;
|
||||
NSVGshape* shapesTail;
|
||||
NSVGpath* paths;
|
||||
struct NSVGsymbol *next;
|
||||
} NSVGsymbol;
|
||||
|
||||
@ -571,7 +579,7 @@ struct NSVGrasterizer
|
||||
int width, height, stride;
|
||||
};
|
||||
|
||||
extern NSVGfont *fontsDB;
|
||||
extern NSVGfontChain *fontsDB;
|
||||
extern struct NSVGparser *mainParser;
|
||||
|
||||
#endif
|
||||
|
@ -59,7 +59,7 @@ EG_IMAGE *FontImage = NULL;
|
||||
INTN FontWidth = 9;
|
||||
INTN FontHeight = 18;
|
||||
INTN TextHeight = 19;
|
||||
NSVGfont *fontsDB = NULL;
|
||||
NSVGfontChain *fontsDB = NULL;
|
||||
|
||||
|
||||
CONST EG_PIXEL SemiWhitePixel = {255, 255, 255, 210}; //semitransparent
|
||||
|
@ -628,13 +628,16 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
|
||||
// mainParser
|
||||
// BuiltinIcons
|
||||
// OSIcons
|
||||
font = fontsDB;
|
||||
while (font) {
|
||||
nextFont = font->next;
|
||||
NSVGfontChain *fontChain = fontsDB;
|
||||
while (fontChain) {
|
||||
font = fontChain->font;
|
||||
if (font) {
|
||||
nsvg__deleteFont(font);
|
||||
font = nextFont;
|
||||
fontChain->font = NULL;
|
||||
}
|
||||
nsvg__deleteParser(mainParser);
|
||||
fontChain = fontChain->next;
|
||||
}
|
||||
// nsvg__deleteParser(mainParser); //temporary disabled
|
||||
//destruct_globals_objects(NULL); //we can't destruct our globals here. We need, for example, Volumes.
|
||||
|
||||
//DumpKernelAndKextPatches(Entry->KernelAndKextPatches);
|
||||
|
Loading…
Reference in New Issue
Block a user