You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.2 KiB

  1. #!/bin/bash
  2. #
  3. # make macos icons using Inkscape
  4. mkdir macos_tmp
  5. # convert .svg files into .png files
  6. SIZES="16x16
  7. 32x32
  8. 128x128
  9. 256x256
  10. 512x512
  11. 1024x1024"
  12. ICONS="bitmap2component
  13. eeschema
  14. gerbview
  15. kicad
  16. pagelayout_editor
  17. pcbcalculator
  18. pcbnew"
  19. DOCS="project
  20. schematic
  21. pcb
  22. footprint
  23. symbol
  24. worksheet"
  25. for doc in $DOCS
  26. do
  27. output=""
  28. for size in $SIZES
  29. do
  30. sz=${size%x*}
  31. echo -e '\E[0;32m'"\nMaking the documents icons with size $size."
  32. # MacOS wants icons with 10% clearance on each side
  33. let "sub_sz = $sz * 8 / 10"
  34. sigma=3
  35. if [ $sz -eq 16 ]
  36. then
  37. sigma=2
  38. elif [ $sz -ge 512 ]
  39. then
  40. sigma=5
  41. fi
  42. # Offset the drop shadow by one smaller than the kernel
  43. let "off = $sigma - 1"
  44. # Use specialized icons for smaller sizes to keep pixel alignment
  45. if [ $sz -le 32 ]
  46. then
  47. inkscape linux/icons/hicolor/scalable/mimetypes/application-x-kicad-${doc}-${sz}.svg -o macos_tmp/${doc}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
  48. else
  49. inkscape linux/icons/hicolor/scalable/mimetypes/application-x-kicad-${doc}.svg -o macos_tmp/${doc}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
  50. fi
  51. convert macos_tmp/${doc}_small_${sz}px.png \( +clone -background black -shadow 80x${sigma}+${off}+${off} \) +swap -background transparent -layers merge +repage -size $size xc:transparent +swap -gravity center -composite macos_tmp/${doc}_${sz}px.png
  52. output+="macos_tmp/${doc}_${sz}px.png "
  53. done
  54. png2icns macos_tmp/${doc}.icns ${output}
  55. done
  56. for pgm in $ICONS
  57. do
  58. output=""
  59. for size in $SIZES
  60. do
  61. sz=${size%x*}
  62. echo -e '\E[0;32m'"\nMaking the applications icons with size $size."
  63. # MacOS wants icons with 10% clearance on each side
  64. let "sub_sz = $sz * 8 / 10"
  65. sigma=3
  66. if [ $sz -eq 16 ]
  67. then
  68. sigma=2
  69. elif [ $sz -ge 512 ]
  70. then
  71. sigma=5
  72. fi
  73. # Offset the drop shadow by one smaller than the kernel
  74. let "off = $sigma - 1"
  75. # Use specialized icons for smaller sizes to keep pixel alignment
  76. if [ $sz -le 32 ]
  77. then
  78. inkscape bitmaps_png/sources/light/icon_${pgm}_${sz}.svg -o macos_tmp/${pgm}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
  79. else
  80. inkscape bitmaps_png/sources/light/icon_${pgm}.svg -o macos_tmp/${pgm}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
  81. fi
  82. convert macos_tmp/${pgm}_small_${sz}px.png \( +clone -background black -shadow 80x${sigma}+${off}+${off} \) +swap -background transparent -layers merge +repage -size $size xc:transparent +swap -gravity center -composite macos_tmp/${pgm}_${sz}px.png
  83. output+="macos_tmp/${pgm}_${sz}px.png "
  84. done
  85. case ${pgm} in
  86. pcbcalculator)
  87. # mismatch in the pcbcalculator icon names
  88. png2icns ../pcb_calculator/pcb_calculator.icns ${output}
  89. ;;
  90. bitmap2component)
  91. # bitmap2component does not have associated documents
  92. png2icns ../${pgm}/${pgm}.icns ${output}
  93. ;;
  94. eeschema)
  95. png2icns ../${pgm}/${pgm}.icns ${output}
  96. cp macos_tmp/schematic.icns ../${pgm}/${pgm}_doc.icns
  97. cp macos_tmp/symbol.icns ../${pgm}/libedit_doc.icns
  98. ;;
  99. pcbnew)
  100. png2icns ../${pgm}/${pgm}.icns ${output}
  101. cp macos_tmp/pcb.icns ../${pgm}/${pgm}_doc.icns
  102. cp macos_tmp/footprint.icns ../${pgm}/fpedit_doc.icns
  103. ;;
  104. kicad)
  105. png2icns ../${pgm}/${pgm}.icns ${output}
  106. cp macos_tmp/project.icns ../${pgm}/${pgm}_doc.icns
  107. ;;
  108. pagelayout_editor)
  109. png2icns ../${pgm}/${pgm}.icns ${output}
  110. cp macos_tmp/worksheet.icns ../${pgm}/${pgm}_doc.icns
  111. ;;
  112. *)
  113. png2icns ../${pgm}/${pgm}.icns ${output}
  114. cp ../${pgm}/${pgm}.icns ../${pgm}/${pgm}_doc.icns
  115. ;;
  116. esac
  117. done
  118. # rm -rf macos_tmp