feat: monochrome Noto Emoji subset icons (pin, camera) before watermark lines
This commit is contained in:
+14
-10
@@ -236,18 +236,19 @@ export async function processAndExportPhoto(
|
||||
// 8. Render GPS Geotag Watermark
|
||||
if (useGeotag && gpsInfo) {
|
||||
const fontAsset = Asset.fromModule(require('../../assets/CourierPrime-Regular.ttf'));
|
||||
if (!fontAsset.localUri) {
|
||||
await fontAsset.downloadAsync();
|
||||
}
|
||||
|
||||
const fontData = await FileSystem.readAsStringAsync(fontAsset.localUri!, {
|
||||
encoding: FileSystem.EncodingType.Base64,
|
||||
});
|
||||
const iconFontAsset = Asset.fromModule(require('../../assets/NotoEmoji-GPS.ttf'));
|
||||
await Promise.all([fontAsset.downloadAsync(), iconFontAsset.downloadAsync()]);
|
||||
const [fontData, iconFontData] = await Promise.all([
|
||||
FileSystem.readAsStringAsync(fontAsset.localUri!, { encoding: FileSystem.EncodingType.Base64 }),
|
||||
FileSystem.readAsStringAsync(iconFontAsset.localUri!, { encoding: FileSystem.EncodingType.Base64 }),
|
||||
]);
|
||||
const typeface = Skia.Typeface.MakeFreeTypeFaceFromData(Skia.Data.fromBase64(fontData));
|
||||
const iconTypeface = Skia.Typeface.MakeFreeTypeFaceFromData(Skia.Data.fromBase64(iconFontData));
|
||||
|
||||
if (typeface) {
|
||||
if (typeface && iconTypeface) {
|
||||
const fontSize = Math.round(width * 0.032); // 3.2% of image width
|
||||
const font = Skia.Font(typeface, fontSize);
|
||||
const iconFont = Skia.Font(iconTypeface, fontSize);
|
||||
const textPaint = Skia.Paint();
|
||||
textPaint.setColor(Skia.Color('#f59e0b')); // Amber 500
|
||||
|
||||
@@ -258,9 +259,12 @@ export async function processAndExportPhoto(
|
||||
|
||||
const yOffset = height - (frameId === 'polaroid' ? height * 0.15 : fontSize * 1.5);
|
||||
const xOffset = frameId === 'polaroid' ? width * 0.08 : fontSize * 1.2;
|
||||
const gap = Math.round(fontSize * 1.2); // icon box (~1em) + spacing
|
||||
|
||||
canvas.drawText(`📍 ${locationName}`, xOffset, yOffset - fontSize * 1.4, textPaint, font);
|
||||
canvas.drawText(timestampStr, xOffset, yOffset, textPaint, font);
|
||||
canvas.drawText('📍', xOffset, yOffset - fontSize * 1.4, textPaint, iconFont);
|
||||
canvas.drawText(locationName, xOffset + gap, yOffset - fontSize * 1.4, textPaint, font);
|
||||
canvas.drawText('📷', xOffset, yOffset, textPaint, iconFont);
|
||||
canvas.drawText(timestampStr, xOffset + gap, yOffset, textPaint, font);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user