Skip to content

Commit 95eaf3c

Browse files
committed
1 parent 5c56d66 commit 95eaf3c

File tree

16 files changed

+568
-364
lines changed

16 files changed

+568
-364
lines changed

packages/eez-studio-ui/_stylesheets/project-editor.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4316,4 +4316,8 @@
43164316
.btn-toolbar {
43174317
display: flex;
43184318
}
4319+
}
4320+
4321+
.EezStudio_ArrayElementProperty_Body_Property>.editGlyphs>div>div:first-child {
4322+
display: none;
43194323
}

packages/project-editor/core/object.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ export interface PropertyInfo {
299299

300300
showArrayCollapsedByDefaultInPropertyGrid?: boolean;
301301
hideElementIndexInPropertyGrid?: boolean;
302+
303+
noColSpanForArray?: boolean;
302304
}
303305

304306
export type InheritedValue =

packages/project-editor/features/font/GlyphSelectFieldType.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
FontRenderingEngine,
1717
IFontExtract,
1818
createFontExtract,
19-
Params
19+
ExtractFontParams
2020
} from "project-editor/features/font/font-extract";
2121
import { ProjectContext } from "project-editor/project/context";
2222
import { IFieldComponentProps } from "eez-studio-ui/generic-dialog";
@@ -37,7 +37,7 @@ export const GlyphSelectFieldType = observer(
3737
static contextType = ProjectContext;
3838
declare context: React.ContextType<typeof ProjectContext>;
3939

40-
params: Params | undefined;
40+
params: ExtractFontParams | undefined;
4141
fontExtract: IFontExtract | undefined;
4242
selectedEncoding = observable.box<number | undefined>();
4343
isLoading: boolean;

packages/project-editor/features/font/font-extract/freetype.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
Params,
2+
ExtractFontParams,
33
FontProperties,
44
GlyphProperties,
55
IFontExtract
@@ -37,7 +37,7 @@ export class ExtractFont implements IFontExtract {
3737
fontProperties: FontProperties;
3838

3939
// size is in pt's
40-
constructor(private params: Params) {}
40+
constructor(private params: ExtractFontParams) {}
4141

4242
async start() {
4343
if (!wasmModule) {

packages/project-editor/features/font/font-extract/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ export interface EncodingRange {
5454
mapped_from?: number;
5555
}
5656

57-
export interface Params {
57+
export interface AdditionalFontSourceParams {
58+
absoluteFilePath: string;
59+
embeddedFontFile?: string;
60+
relativeFilePath: string;
61+
size: number;
62+
encodings?: EncodingRange[];
63+
symbols?: string;
64+
}
65+
66+
export interface ExtractFontParams {
5867
name?: string;
5968
absoluteFilePath: string;
6069
embeddedFontFile?: string;
@@ -73,6 +82,7 @@ export interface Params {
7382
lvglInclude?: string;
7483
opts_string?: string;
7584
lv_fallback?: string;
85+
additionalSources?: AdditionalFontSourceParams[];
7686
}
7787

7888
export interface IFontExtract {
@@ -84,7 +94,7 @@ export interface IFontExtract {
8494
allEncodings: number[];
8595
}
8696

87-
export async function createFontExtract(params: Params): Promise<IFontExtract> {
97+
export async function createFontExtract(params: ExtractFontParams): Promise<IFontExtract> {
8898
let renderingEngineModule;
8999

90100
if (params.renderingEngine == "freetype") {
@@ -104,7 +114,7 @@ export async function createFontExtract(params: Params): Promise<IFontExtract> {
104114
return new renderingEngineModule.ExtractFont(params);
105115
}
106116

107-
export async function extractFont(params: Params) {
117+
export async function extractFont(params: ExtractFontParams) {
108118
const extractFont = await createFontExtract(params);
109119
try {
110120
await extractFont.start();

packages/project-editor/features/font/font-extract/lvgl.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
Params,
2+
ExtractFontParams,
33
FontProperties,
44
GlyphProperties,
55
IFontExtract
@@ -18,7 +18,7 @@ export class ExtractFont implements IFontExtract {
1818
allEncodings: number[];
1919
fontData: any;
2020

21-
constructor(private params: Params) {}
21+
constructor(private params: ExtractFontParams) {}
2222

2323
async start() {
2424
let source_bin = this.params.embeddedFontFile
@@ -36,7 +36,7 @@ export class ExtractFont implements IFontExtract {
3636

3737
const symbols = this.params.symbols ?? "";
3838

39-
const font = [
39+
const font: any[] = [
4040
{
4141
source_path: this.params.absoluteFilePath,
4242
source_bin,
@@ -49,6 +49,38 @@ export class ExtractFont implements IFontExtract {
4949
}
5050
];
5151

52+
if (this.params.additionalSources) {
53+
for (const additionalSource of this.params.additionalSources) {
54+
const addSourceBin = additionalSource.embeddedFontFile
55+
? Buffer.from(additionalSource.embeddedFontFile, "base64")
56+
: fs.readFileSync(additionalSource.absoluteFilePath);
57+
58+
const addRange: number[] = [];
59+
if (additionalSource.encodings) {
60+
additionalSource.encodings.map(encodingRange =>
61+
addRange.push(
62+
encodingRange.from,
63+
encodingRange.to,
64+
encodingRange.mapped_from ?? encodingRange.from
65+
)
66+
);
67+
}
68+
69+
const addSymbols = additionalSource.symbols ?? "";
70+
71+
font.push({
72+
source_path: additionalSource.absoluteFilePath,
73+
source_bin: addSourceBin,
74+
ranges: [
75+
{
76+
range: addRange,
77+
symbols: addSymbols
78+
}
79+
]
80+
});
81+
}
82+
}
83+
5284
const output = getName(
5385
"ui_font_",
5486
this.params.name || "",

packages/project-editor/features/font/font-extract/opentype.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { load, parse, Font as OpenTypeFont } from "opentype.js";
33

44
import { toArrayBuffer } from "project-editor/features/font/utils";
55
import type {
6-
Params,
6+
ExtractFontParams,
77
FontProperties,
88
GlyphProperties,
99
IFontExtract
@@ -20,7 +20,7 @@ export class ExtractFont implements IFontExtract {
2020
fontProperties: FontProperties;
2121
allEncodings: number[];
2222

23-
constructor(private params: Params) { }
23+
constructor(private params: ExtractFontParams) { }
2424

2525
async start() {
2626
return new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)