This commit is contained in:
2026-06-13 01:34:45 +02:00
parent 408b29896c
commit 3cb2e466d8
21 changed files with 1285 additions and 130 deletions
@@ -0,0 +1,93 @@
Copyright 2016 The Alfa Slab One Project Authors (http://www.jmsole.cl | info@jmsole.cl), with Reserved Font Name "Alfa Slab".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+94
View File
@@ -0,0 +1,94 @@
Copyright (c) 2011 by Sorkin Type Co (www.sorkintype.com),
with Reserved Font Name "Rye".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
+2
View File
@@ -28,6 +28,8 @@ var fontFiles = []struct {
{"Lilita One", "display", "LilitaOne-Regular.ttf", false},
{"Baloo 2", "display", "Baloo2-Variable.ttf", true},
{"Oswald", "display", "Oswald-Variable.ttf", true},
{"Alfa Slab One", "display", "AlfaSlabOne-Regular.ttf", false}, // heavy slab serif (HS0ZLE-style)
{"Rye", "display", "Rye-Regular.ttf", false}, // Western slab
{"Great Vibes", "script", "GreatVibes-Regular.ttf", false},
{"Allura", "script", "Allura-Regular.ttf", false},
}
+68 -46
View File
@@ -59,6 +59,8 @@ type ProfileInfo struct {
Grid string
CQZone int
ITUZone int
Rig string
Antenna string
}
// LayoutEngine proposes card templates from analyzed photos. The heuristic
@@ -253,27 +255,24 @@ func (HeuristicEngine) Propose(photos []PhotoAnalysis, profile ProfileInfo) ([]T
cool: sorted[0].Warmth < 0.02,
}
if len(sorted) > 1 {
plan.inserts = sorted[1:min(len(sorted), 5)] // up to 4 (bottom strip), side column uses 3
plan.inserts = sorted[1:min(len(sorted), 3)] // hero + up to 2 inserts
}
// Only side-column inserts (or none): a bottom strip collides with the QSO
// box, which is what produced the overlapping mess.
primary := ArchetypeSideColumn
if len(plan.inserts) == 0 {
primary = ArchetypeFullBleed
} else if len(plan.inserts) >= 4 && bandQuiet(plan.hero, gridRows-5, gridRows) {
primary = ArchetypeBottomStrip
}
alternate := alternateArchetype(primary, len(plan.inserts))
// Three proposals that vary BOTH the call style and its vertical position
// (top / bottom / natural-best), so the user gets genuinely distinct cards
// to choose from rather than three near-identical golds.
styles := []string{"gel_gold", "gel_silver", "classic_white_outline"}
if plan.cool {
styles[0], styles[1] = styles[1], styles[0] // lead with silver on cool photos
}
p1 := buildTemplateBiased(plan, primary, styles[0], flipTop)
p2 := buildTemplateBiased(plan, alternate, styles[1], flipBottom)
p3 := buildTemplateBiased(plan, alternate, styles[2], flipNatural)
// Three proposals that showcase genuinely different call looks (font +
// style + position), echoing the classic printed-QSL styles: a rounded
// glossy gold, a distressed slab "vintage", and an angular silver. The
// middle one is a clean full-bleed (no inserts) so the set always offers a
// minimal option.
p1 := buildTemplateBiased(plan, primary, "gel_gold", "Baloo 2", flipTop)
p2 := buildTemplateBiased(plan, ArchetypeFullBleed, "gel_gold_grunge", "Alfa Slab One", flipBottom)
p3 := buildTemplateBiased(plan, primary, "gel_silver", "Archivo Black", flipNatural)
out := []Template{p1, p2, p3}
for i := range out {
@@ -285,20 +284,6 @@ func (HeuristicEngine) Propose(photos []PhotoAnalysis, profile ProfileInfo) ([]T
return out, nil
}
func alternateArchetype(primary string, inserts int) string {
switch primary {
case ArchetypeSideColumn:
if inserts >= 2 {
return ArchetypeBottomStrip
}
return ArchetypeFullBleed
case ArchetypeBottomStrip:
return ArchetypeSideColumn
default:
return ArchetypeFullBleed
}
}
func archetypeLabel(t Template) string {
inserts := 0
for _, e := range t.Elements {
@@ -312,20 +297,6 @@ func archetypeLabel(t Template) string {
return "with inserts"
}
// bandQuiet reports whether the mean detail of grid rows [r0,r1) is low
// enough to host inserts or text.
func bandQuiet(p PhotoAnalysis, r0, r1 int) bool {
var sum float64
n := 0
for r := r0; r < r1; r++ {
for c := 0; c < gridCols; c++ {
sum += p.Cells[r][c].Detail
n++
}
}
return n > 0 && sum/float64(n) < 0.25
}
// pxRect is a rectangle in card pixel space.
type pxRect struct{ x, y, w, h float64 }
@@ -336,7 +307,23 @@ const (
flipBottom // restrict the callsign to the bottom half
)
func buildTemplateBiased(plan proposalPlan, archetype, style string, flip int) Template {
// charWidthFactor is a rough per-font average glyph width (in ems) for the
// heavy display faces, used to size the callsign so it fills its zone without
// overflowing. The frontend can refine with real measureText later.
func charWidthFactor(font string) float64 {
switch font {
case "Alfa Slab One", "Rye":
return 0.82
case "Baloo 2":
return 0.72
case "Oswald":
return 0.55
default: // Archivo Black, Lilita One
return 0.72
}
}
func buildTemplateBiased(plan proposalPlan, archetype, style, font string, flip int) Template {
hero := plan.hero
crop := cropForCard(hero)
@@ -371,13 +358,14 @@ func buildTemplateBiased(plan proposalPlan, archetype, style string, flip int) T
params := adaptStyle(style, zoneLuma, hero.Warmth)
call := plan.profile.Callsign
size := math.Min(zone.w*0.9/(0.72*float64(max(len(call), 3))), zone.h*0.95)
callW := 0.72 * size * float64(len(call))
cw := charWidthFactor(font)
size := math.Min(zone.w*0.9/(cw*float64(max(len(call), 3))), zone.h*0.95)
callW := cw * size * float64(len(call))
callX := zone.x + (zone.w-callW)/2
callY := zone.y + (zone.h-size)*0.3
t.Elements = append(t.Elements, Element{
Type: ElemCallsign, Text: "{profile.callsign}",
Font: FontDisplayDefault, Size: math.Round(size),
Font: font, Size: math.Round(size),
X: math.Round(clamp(callX, 40, cardW-80)), Y: math.Round(clamp(callY, 30, cardH-size-30)),
StylePreset: style, StyleParams: params,
})
@@ -417,6 +405,22 @@ func buildTemplateBiased(plan proposalPlan, archetype, style string, flip int) T
StyleParams: &StyleParams{OutlineColor: "#22364e", OutlineWidth: 5},
})
// Operating conditions (rig / antenna), stacked next to the zones line.
// Always added so the "Show on card" toggle exists, but hidden by default
// when the profile has no rig/antenna yet (avoids an empty "Rig · Ant").
txt, stationHidden := stationLineText(plan.profile)
stationY := infoY + 40
if infoY < callY { // zones line sits above the call → stack station above it
stationY = infoY - 40
}
t.Elements = append(t.Elements, Element{
Type: ElemInfoLine, Text: txt, Hidden: stationHidden,
Font: FontInfoLine, Size: 26,
X: math.Round(clamp(zone.x, 40, cardW-700)), Y: math.Round(clamp(stationY, 30, cardH-60)),
StylePreset: "outlined_white",
StyleParams: &StyleParams{OutlineColor: "#22364e", OutlineWidth: 5},
})
occupied := []pxRect{zone}
if hasInserts {
t.Elements = append(t.Elements, insertEls...)
@@ -435,6 +439,24 @@ func buildTemplateBiased(plan proposalPlan, archetype, style string, flip int) T
return t
}
// stationLineText builds the rig/antenna line for the profile and whether it
// should start hidden. When the profile has neither, it returns the full
// template text with hidden=true so the editor still offers the toggle (it
// resolves cleanly once the user fills My rig / My antenna). Values fill in
// from {profile.*} at render time.
func stationLineText(p ProfileInfo) (text string, hidden bool) {
switch {
case p.Rig != "" && p.Antenna != "":
return "Rig {qso.my_rig} · Ant {qso.my_antenna}", false
case p.Rig != "":
return "Rig {qso.my_rig}", false
case p.Antenna != "":
return "Ant {qso.my_antenna}", false
default:
return "Rig {qso.my_rig} · Ant {qso.my_antenna}", true
}
}
// cropForCard crops the photo to the card aspect ratio, sliding the window
// toward the detail centroid so the interesting content stays visible.
func cropForCard(p PhotoAnalysis) Crop {
+14 -10
View File
@@ -164,19 +164,23 @@ func TestProposeThreeDistinctWithInserts(t *testing.T) {
t.Errorf("proposal %d invalid: %v", i, err)
}
}
// The three proposals must use three distinct call styles from the palette
// (the user asked for variety in both style and position).
allowed := map[string]bool{"gel_gold": true, "gel_silver": true, "classic_white_outline": true}
seen := map[string]bool{}
// The three proposals must showcase distinct call looks: each style is a
// known preset, and no two proposals share the same font+style pairing.
seenStyle := map[string]bool{}
seenFont := map[string]bool{}
for i, tmpl := range out {
s := findElement(t, tmpl, ElemCallsign).StylePreset
if !allowed[s] {
t.Errorf("proposal %d: unexpected call style %q", i, s)
call := findElement(t, tmpl, ElemCallsign)
if _, ok := Presets[call.StylePreset]; !ok {
t.Errorf("proposal %d: unknown call style %q", i, call.StylePreset)
}
if seen[s] {
t.Errorf("proposal %d reuses call style %q", i, s)
if seenStyle[call.StylePreset] {
t.Errorf("proposal %d reuses call style %q", i, call.StylePreset)
}
seen[s] = true
if seenFont[call.Font] {
t.Errorf("proposal %d reuses call font %q", i, call.Font)
}
seenStyle[call.StylePreset] = true
seenFont[call.Font] = true
}
// At least one proposal uses the insert photos.
if countInserts(out[0]) == 0 && countInserts(out[1]) == 0 && countInserts(out[2]) == 0 {
+36 -10
View File
@@ -23,12 +23,12 @@ var Presets = map[string]Preset{
Label: "Gel gold",
AllowedParams: gelParams,
Defaults: StyleParams{
Gradient: []string{"#FFD83A", "#FFC312", "#EE9400"},
Shine: &Shine{Coverage: 0.5, Opacity: 0.95},
OutlineColor: "#2a3f5c", OutlineWidth: 9,
Gradient: []string{"#FFE15A", "#FFC312", "#E07A00"},
Shine: &Shine{Coverage: 0.52, Opacity: 0.95},
OutlineColor: "#2a3f5c", OutlineWidth: 10,
Halo: &Halo{Color: "#cdd9e4", Blur: 6, Opacity: 0.4},
Shadow: &ShadowFx{Dx: 5, Dy: 8, Blur: 5, Color: "#14243a", Opacity: 0.5},
BevelOffset: &Bevel{Dx: -2, Dy: -4, Dark: "#C27500", Light: "#FFEFA0"},
Shadow: &ShadowFx{Dx: 6, Dy: 9, Blur: 5, Color: "#14243a", Opacity: 0.55},
BevelOffset: &Bevel{Dx: -3, Dy: -6, Dark: "#A85F00", Light: "#FFF6C8"},
},
},
"gel_silver": {
@@ -36,12 +36,38 @@ var Presets = map[string]Preset{
Label: "Gel silver",
AllowedParams: gelParams,
Defaults: StyleParams{
Gradient: []string{"#F4F7FA", "#C9D4DE", "#93A3B3"},
Shine: &Shine{Coverage: 0.5, Opacity: 0.95},
OutlineColor: "#3c4654", OutlineWidth: 9,
Gradient: []string{"#FBFDFF", "#C9D4DE", "#8496A8"},
Shine: &Shine{Coverage: 0.52, Opacity: 0.95},
OutlineColor: "#3c4654", OutlineWidth: 10,
Halo: &Halo{Color: "#dfe7ee", Blur: 6, Opacity: 0.4},
Shadow: &ShadowFx{Dx: 5, Dy: 8, Blur: 5, Color: "#1b2530", Opacity: 0.5},
BevelOffset: &Bevel{Dx: -2, Dy: -4, Dark: "#76879a", Light: "#FFFFFF"},
Shadow: &ShadowFx{Dx: 6, Dy: 9, Blur: 5, Color: "#1b2530", Opacity: 0.55},
BevelOffset: &Bevel{Dx: -3, Dy: -6, Dark: "#67788b", Light: "#FFFFFF"},
},
},
"gel_gold_grunge": {
Name: "gel_gold_grunge",
Label: "Gel gold (vintage)",
AllowedParams: gelParams,
Defaults: StyleParams{
Gradient: []string{"#FFC83A", "#F0A21E", "#D87A00"},
Shine: &Shine{Coverage: 0.42, Opacity: 0.8},
OutlineColor: "#1c130a", OutlineWidth: 11,
Halo: &Halo{Color: "#d8c08a", Blur: 5, Opacity: 0.3},
Shadow: &ShadowFx{Dx: 5, Dy: 8, Blur: 4, Color: "#1a0f04", Opacity: 0.55},
BevelOffset: &Bevel{Dx: -2, Dy: -4, Dark: "#A85F00", Light: "#FFE08A"},
},
},
"gel_silver_grunge": {
Name: "gel_silver_grunge",
Label: "Gel silver (vintage)",
AllowedParams: gelParams,
Defaults: StyleParams{
Gradient: []string{"#EEF2F6", "#C2CDD8", "#8593A3"},
Shine: &Shine{Coverage: 0.42, Opacity: 0.8},
OutlineColor: "#16191f", OutlineWidth: 11,
Halo: &Halo{Color: "#cdd6df", Blur: 5, Opacity: 0.3},
Shadow: &ShadowFx{Dx: 5, Dy: 8, Blur: 4, Color: "#10141a", Opacity: 0.55},
BevelOffset: &Bevel{Dx: -2, Dy: -4, Dark: "#6c7d8f", Light: "#FFFFFF"},
},
},
"classic_white_outline": {
+1
View File
@@ -138,6 +138,7 @@ type Element struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Rotate float64 `json:"rotate,omitempty"`
Hidden bool `json:"hidden,omitempty"` // toggled off in the editor; kept in the template
// Text elements (callsign / operator / info_line).
Text string `json:"text,omitempty"`