-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes in text nodes * fix comment * allow design.penpot.app * wip * wip * add position data * wip agaaain * added translate growtype * use a random url just to get a 404 on gfonts call * leave the config, just in case someone wants to try it * translated line height & letter spacing; Created new type for text positionData * text strokes * several fixes * compiled penpot lib with fix * updated penpot lib * fix lint * remove proxy * correctly translate font style * fix grow type to reflect vertical trim * Fix font segments * remove comment * changeset --------- Co-authored-by: Alex Sánchez <sion333@gmail.com>
- Loading branch information
1 parent
942b393
commit 881ccab
Showing
19 changed files
with
5,525 additions
and
5,475 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 | ||
--- | ||
|
||
Added text basic properties |
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,8 +1,15 @@ | ||
export * from './translateBlendMode'; | ||
export * from './translateShadowEffects'; | ||
export * from './translateFills'; | ||
export * from './translateFontStyle'; | ||
export * from './translateFontVariantId'; | ||
export * from './translateGrowType'; | ||
export * from './translateHorizontalAlign'; | ||
export * from './translateLetterSpacing'; | ||
export * from './translateLineHeight'; | ||
export * from './translateStrokes'; | ||
export * from './translateStyledTextSegments'; | ||
export * from './translateTextDecoration'; | ||
export * from './translateTextTransform'; | ||
export * from './translateVectorPaths'; | ||
export * from './translateVerticalAlign'; |
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,9 @@ | ||
import { TextFontStyle } from '@ui/lib/types/text/textContent'; | ||
|
||
export const translateFontStyle = (style: string): TextFontStyle => { | ||
if (style.toLowerCase().includes('italic')) { | ||
return 'italic'; | ||
} | ||
|
||
return 'normal'; | ||
}; |
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,3 @@ | ||
export const translateFontVariantId = (style: string) => { | ||
return style.toLowerCase().replace(/\s/g, ''); | ||
}; |
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,17 @@ | ||
import { GrowType } from '@ui/lib/types/shape/shapeAttributes'; | ||
|
||
export const translateGrowType = (node: TextNode): GrowType => { | ||
if (node.leadingTrim === 'CAP_HEIGHT') { | ||
return 'fixed'; | ||
} | ||
|
||
switch (node.textAutoResize) { | ||
case 'WIDTH_AND_HEIGHT': | ||
return 'auto-width'; | ||
case 'HEIGHT': | ||
return 'auto-height'; | ||
case 'TRUNCATE': | ||
default: | ||
return 'fixed'; | ||
} | ||
}; |
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,16 @@ | ||
import { TextHorizontalAlign } from '@ui/lib/types/text/textContent'; | ||
|
||
export const translateHorizontalAlign = ( | ||
align: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED' | ||
): TextHorizontalAlign => { | ||
switch (align) { | ||
case 'RIGHT': | ||
return 'right'; | ||
case 'CENTER': | ||
return 'center'; | ||
case 'JUSTIFIED': | ||
return 'justify'; | ||
default: | ||
return 'left'; | ||
} | ||
}; |
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,12 @@ | ||
export const translateLetterSpacing = ( | ||
segment: Pick<StyledTextSegment, 'letterSpacing' | 'fontSize'> | ||
): number => { | ||
switch (segment.letterSpacing.unit) { | ||
case 'PIXELS': | ||
return segment.letterSpacing.value; | ||
case 'PERCENT': | ||
return (segment.fontSize * segment.letterSpacing.value) / 100; | ||
default: | ||
return 0; | ||
} | ||
}; |
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,10 @@ | ||
export const translateLineHeight = ( | ||
segment: Pick<StyledTextSegment, 'lineHeight' | 'fontSize'> | ||
): number | undefined => { | ||
switch (segment.lineHeight.unit) { | ||
case 'PIXELS': | ||
return segment.lineHeight.value / segment.fontSize; | ||
case 'PERCENT': | ||
return segment.lineHeight.value / 100; | ||
} | ||
}; |
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,12 @@ | ||
import { TextVerticalAlign } from '@ui/lib/types/text/textContent'; | ||
|
||
export const translateVerticalAlign = (align: 'TOP' | 'CENTER' | 'BOTTOM'): TextVerticalAlign => { | ||
switch (align) { | ||
case 'BOTTOM': | ||
return 'bottom'; | ||
case 'CENTER': | ||
return 'center'; | ||
default: | ||
return 'top'; | ||
} | ||
}; |
Oops, something went wrong.