-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* color library * fixes * wip * wip * wip * wip * working * improvements * changeset * changeset * changeset & cleaning * changeset & cleaning * improvements * fixes * rebase
- Loading branch information
Showing
42 changed files
with
506 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"penpot-exporter": minor | ||
--- | ||
|
||
Add support for typographies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"penpot-exporter": patch | ||
--- | ||
|
||
Improve font weight translation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"penpot-exporter": patch | ||
--- | ||
|
||
Fix letter spacing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class TextLibrary { | ||
private styles: Map<string, TextStyle | undefined> = new Map(); | ||
|
||
public register(id: string, styles?: TextStyle | undefined) { | ||
this.styles.set(id, styles); | ||
} | ||
|
||
public get(id: string): TextStyle | undefined { | ||
return this.styles.get(id); | ||
} | ||
|
||
public has(id: string): boolean { | ||
return this.styles.has(id); | ||
} | ||
|
||
public all(): Record<string, TextStyle | undefined> { | ||
return Object.fromEntries(this.styles.entries()); | ||
} | ||
} | ||
|
||
export const textLibrary = new TextLibrary(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './translateFills'; | ||
export * from './translateImageFill'; | ||
export * from './translatePaintStyles'; | ||
export * from './translateSolidFill'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './translatePaintStyle'; | ||
export * from './translateTextStyle'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { translateFontName } from '@plugin/translators/text/font'; | ||
import { | ||
translateFontStyle, | ||
translateLetterSpacing, | ||
translateLineHeight, | ||
translateTextDecoration, | ||
translateTextTransform | ||
} from '@plugin/translators/text/properties'; | ||
|
||
import { TypographyStyle } from '@ui/lib/types/shapes/textShape'; | ||
|
||
export const translateTextStyle = (figmaStyle: TextStyle): TypographyStyle => { | ||
const path = figmaStyle.remote ? 'Remote / ' : ''; | ||
|
||
return { | ||
name: figmaStyle.name, | ||
textStyle: { | ||
...translateFontName(figmaStyle.fontName), | ||
fontFamily: figmaStyle.fontName.family, | ||
fontSize: figmaStyle.fontSize.toString(), | ||
fontStyle: translateFontStyle(figmaStyle.fontName.style), | ||
textDecoration: translateTextDecoration(figmaStyle), | ||
letterSpacing: translateLetterSpacing(figmaStyle), | ||
textTransform: translateTextTransform(figmaStyle), | ||
lineHeight: translateLineHeight(figmaStyle) | ||
}, | ||
typography: { | ||
path, | ||
name: figmaStyle.name | ||
} | ||
}; | ||
}; |
13 changes: 9 additions & 4 deletions
13
plugin-src/translators/text/font/custom/translateCustomFont.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { getCustomFontId, translateFontVariantId } from '@plugin/translators/text/font/custom'; | ||
|
||
import { FontId } from '@ui/lib/types/shapes/textShape'; | ||
import { TextTypography } from '@ui/lib/types/shapes/textShape'; | ||
|
||
export const translateCustomFont = (fontName: FontName, fontWeight: number): FontId | undefined => { | ||
export const translateCustomFont = ( | ||
fontName: FontName, | ||
fontWeight: string | ||
): Pick<TextTypography, 'fontId' | 'fontVariantId' | 'fontWeight'> | undefined => { | ||
const customFontId = getCustomFontId(fontName); | ||
return { | ||
fontId: `custom-${getCustomFontId(fontName)}`, | ||
fontVariantId: translateFontVariantId(fontName, fontWeight) | ||
fontId: customFontId ? `custom-${customFontId}` : '', | ||
fontVariantId: translateFontVariantId(fontName, fontWeight), | ||
fontWeight | ||
}; | ||
}; |
4 changes: 2 additions & 2 deletions
4
plugin-src/translators/text/font/custom/translateFontVariantId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const translateFontVariantId = (fontName: FontName, fontWeight: number) => { | ||
export const translateFontVariantId = (fontName: FontName, fontWeight: string) => { | ||
const style = fontName.style.toLowerCase().includes('italic') ? 'italic' : 'normal'; | ||
|
||
return `${style}-${fontWeight.toString()}`; | ||
return `${style}-${fontWeight}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './translateFontId'; | ||
export * from './translateFontName'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
plugin-src/translators/text/font/local/translateLocalFont.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.